Skip to content

Commit

Permalink
add User Agent, remove empty ee.Initialize(), update ee.Initialize() …
Browse files Browse the repository at this point in the history
…in the README.md
  • Loading branch information
gena committed Nov 9, 2024
1 parent 9bdb4fd commit 43bb691
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ee.Authenticate()
```python
import ee
from ee_plugin import Map
ee.Initialize()
ee.Initialize(project="<your google cloud project name with EE registered>")

# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')
Expand Down
11 changes: 10 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import site
import pkg_resources

__version__ = '0.0.7'

def add_ee_dependencies():
extra_libs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'extlibs'))

Expand All @@ -24,7 +26,14 @@ def classFactory(iface): # pylint: disable=invalid-name
# load EE python dependencies
add_ee_dependencies()

# authenticate and initialize EE
# set User Agent for all calls
import ee
user_agent = f'QGIS_EE/{__version__}'
if ee.data.getUserAgent() != user_agent:
ee.data.setUserAgent(user_agent)


# authenticate and initialize EE
from . import ee_auth
ee_auth.authenticate_and_set_project()

Expand Down
5 changes: 0 additions & 5 deletions ee_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ def updateLayers(self):
print('\nWARNING:\n Map layer saved with older version of EE plugin is detected, backward-compatibility for versions before 0.0.3 is not supported due to changes in EE library, please re-create EE layer by re-running the Python script\n')
return

# needed to load EE objects saved in QGIS projects
# TODO: it does not work for init EE in a Google Cloud Project, see #150
if not ee.data.is_initialized():
ee.Initialize()

ee_object = ee.deserializer.fromJSON(ee_object)

if ee_object_vis is not None:
Expand Down

0 comments on commit 43bb691

Please sign in to comment.