eath_engine intro
In [1]:
Copied!
import ee
import geogee
import ee
import geogee
C:\Users\Sarath_Kin\miniconda3\envs\demo310\lib\site-packages\google\api_core\_python_version_support.py:266: FutureWarning: You are using a Python version (3.10.19) which Google will stop supporting in new releases of google.api_core once it reaches its end of life (2026-10-04). Please upgrade to the latest Python version, or at least Python 3.11, to continue receiving updates for google.api_core past that date. warnings.warn(message, FutureWarning)
In [2]:
Copied!
Map = geogee.Map()
Map
Map = geogee.Map()
Map
Out[2]:
In [3]:
Copied!
geogee.ee_initialize()
geogee.ee_initialize()
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[3], line 1 ----> 1 geogee.ee_initialize() File L:\Coding\Github\geogee\geogee\common.py:16, in ee_initialize(token_name) 14 def ee_initialize(token_name="EARTHENGINE_TOKEN"): 15 """Authenticates Earth Engine and initialize an Earth Engine session""" ---> 16 if ee.data._credentials is None: 17 try: 18 ee_token = os.environ.get(token_name) AttributeError: module 'ee.data' has no attribute '_credentials'
In [4]:
Copied!
dem = ee.Image('USGS/SRTMGL1_003')
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}
dem = ee.Image('USGS/SRTMGL1_003')
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']}
--------------------------------------------------------------------------- EEException Traceback (most recent call last) Cell In[4], line 1 ----> 1 dem = ee.Image('USGS/SRTMGL1_003') 3 vis_params = { 4 'min': 0, 5 'max': 4000, 6 'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5']} File ~\miniconda3\envs\demo310\lib\site-packages\ee\computedobject.py:29, in ComputedObjectMetaclass.__call__(cls, *args, **kwargs) 27 return args[0] 28 else: ---> 29 return type.__call__(cls, *args, **kwargs) File ~\miniconda3\envs\demo310\lib\site-packages\ee\deprecation.py:127, in WarnForDeprecatedAsset.<locals>.Decorator.<locals>.Wrapper(*args, **kwargs) 125 if asset: 126 _IssueAssetDeprecationWarning(asset) --> 127 return func(*args, **kwargs) File ~\miniconda3\envs\demo310\lib\site-packages\ee\image.py:73, in Image.__init__(self, args, version) 54 @deprecation.WarnForDeprecatedAsset('args') 55 def __init__(self, args: Any | None = None, version: float | None = None): 56 """Constructs an Earth Engine image. 57 58 Args: (...) 71 EEException: if passed something other than the above. 72 """ ---> 73 self.initialize() 75 if version is not None: 76 if ee_types.isString(args) and ee_types.isNumber(version): 77 # An ID and version. File ~\miniconda3\envs\demo310\lib\site-packages\ee\image.py:119, in Image.initialize(cls) 117 """Imports API functions to this class.""" 118 if not cls._initialized: --> 119 apifunction.ApiFunction.importApi(cls, cls.name(), cls.name()) 120 cls._initialized = True File ~\miniconda3\envs\demo310\lib\site-packages\ee\_utils.py:39, in accept_opt_prefix.<locals>.opt_fixed.<locals>.wrapper(*args, **kwargs) 37 if new_key not in kwargs: 38 kwargs[new_key] = old_key_val ---> 39 return func(*args, **kwargs) File ~\miniconda3\envs\demo310\lib\site-packages\ee\apifunction.py:199, in ApiFunction.importApi(cls, target, prefix, type_name, prepend) 179 @classmethod 180 @_utils.accept_opt_prefix('opt_prepend') 181 def importApi( (...) 186 prepend: str | None = None, 187 ) -> None: 188 """Adds all API functions that begin with a given prefix to a target class. 189 190 Args: (...) 197 functions. 198 """ --> 199 cls.initialize() 200 prepend = prepend or '' 201 for name, api_func in cls._api.items(): File ~\miniconda3\envs\demo310\lib\site-packages\ee\apifunction.py:163, in ApiFunction.initialize(cls) 161 """Initializes the list of signatures from the Earth Engine front-end.""" 162 if not cls._api: --> 163 signatures = data.getAlgorithms() 164 api = {} 165 for name, sig in signatures.items(): 166 # Strip type parameters. File ~\miniconda3\envs\demo310\lib\site-packages\ee\data.py:1421, in getAlgorithms() 1404 """Get the list of algorithms. 1405 1406 Returns: (...) 1417 is not specified. 1418 """ 1419 try: 1420 call = ( -> 1421 _get_cloud_projects() 1422 .algorithms() 1423 .list(parent=_get_projects_path(), prettyPrint=False) 1424 ) 1425 except TypeError: 1426 call = ( 1427 _get_cloud_projects() 1428 .algorithms() 1429 .list(project=_get_projects_path(), prettyPrint=False) 1430 ) File ~\miniconda3\envs\demo310\lib\site-packages\ee\data.py:289, in _get_cloud_projects() 287 state = _get_state() 288 if state.cloud_api_resource is None: --> 289 raise ee_exception.EEException(_NOT_INITIALIZED_MESSAGE) 290 return state.cloud_api_resource.projects() EEException: Earth Engine client library not initialized. See http://goo.gle/ee-auth.
In [5]:
Copied!
ee_layer = geogee.ee_tile_layer(dem, vis_params, "DEM")
ee_layer = geogee.ee_tile_layer(dem, vis_params, "DEM")
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[5], line 1 ----> 1 ee_layer = geogee.ee_tile_layer(dem, vis_params, "DEM") AttributeError: module 'geogee' has no attribute 'ee_tile_layer'
In [6]:
Copied!
Map.add_layer(ee_layer)
Map.add_layer(ee_layer)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[6], line 1 ----> 1 Map.add_layer(ee_layer) NameError: name 'ee_layer' is not defined
In [7]:
Copied!
# Map.addLayer(dem, vis_params, "DEM")
# Map.addLayer(dem, vis_params, "DEM")
In [8]:
Copied!
import ipywidgets as widgets
import ipywidgets as widgets
In [9]:
Copied!
slider = widgets.FloatSlider(min=0, max=1, step=0.01)
slider
slider = widgets.FloatSlider(min=0, max=1, step=0.01)
slider
Out[9]:
In [10]:
Copied!
widgets.jslink((ee_layer, "opacity"), (slider, "value"))
widgets.jslink((ee_layer, "opacity"), (slider, "value"))
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Cell In[10], line 1 ----> 1 widgets.jslink((ee_layer, "opacity"), (slider, "value")) NameError: name 'ee_layer' is not defined
In [11]:
Copied!
from ipyleaflet import WidgetControl
from ipyleaflet import WidgetControl
In [12]:
Copied!
control = WidgetControl(widget=slider, position="bottomright")
Map.add_control(control)
control = WidgetControl(widget=slider, position="bottomright")
Map.add_control(control)
In [ ]:
Copied!