Digital elevation data is an international research effort that obtained digital elevation models on a near-global scale. This SRTM V3 product (SRTM Plus) is provided by NASA JPL at a resolution of 1 arc-second (approximately 30m).
The Google Earth Engine (GEE) Python API facilitates interacting with Earth Engine servers using the Python programming language. It is available as a Python package that can be installed locally or within the cloud and accessed from a command-line interpreter or within a Jupyter notebook.
Set up Python API for GEE and continue following
Step 1
The Python API package is called ee. It must also be initialized for every new session and script.
# import Google earth engine module import ee #Authenticate the Google earth engine with google account ee.Initialize()
Step 2
To render GEE Tile Layers in python API, there is a python library called Folium which helps create the interactive map based on Leaflet JS. Install Folium as PIP
pip install folium
Now import Folium and set the satellite image to get an interactive map with GEE WMS
#import module
import folium
#Define year startyear = 2019; endyear = 2019; #Create the Date object startdate = ee.Date.fromYMD(startyear,1,1); enddate = ee.Date.fromYMD(endyear,12,1); # Define a method for displaying Earth Engine image tiles on a folium map. def add_ee_layer(self, ee_object, vis_params, name): try: # display ee.Image() if isinstance(ee_object, ee.image.Image): map_id_dict = ee.Image(ee_object).getMapId(vis_params) folium.raster_layers.TileLayer( tiles = map_id_dict['tile_fetcher'].url_format, attr = 'Google Earth Engine', name = name, overlay = True, control = True ).add_to(self) except: print("Could not display {}".format(name)) # Add EE drawing method to folium. folium.Map.add_ee_layer = add_ee_layer #Load the SRTM image. srtm = ee.Image('USGS/SRTMGL1_003'); #Apply slope algorithm to an image. slope = ee.Terrain.slope(srtm); #Scale and Projection scale = srtm.projection().nominalScale(); #styling visualization_params = {min: 0, max: 10000, 'palette': [ '3ae237', 'b5e22e', 'd6e21f', 'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d', 'ff0000', 'de0101', 'c21301', '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef', '3be285', '3ff38f', '86e26f' ],}; # Add the data to the map object. my_map.add_ee_layer(srtm, visualization_params ,"DEM"); my_map.add_ee_layer(slope, visualization_params , "slope"); # Display the map. display(my_map)
In the above code, SRTM Elevation and Slope are generated and displayed in the interactive map with the folium module. To generate HTML output of the above result use:
my_map.save('index.html')
mi da questo errore #Create the Date object startdate = ee.Date.fromYMD(exceptstartyear,1,1); enddate = ee.Date.fromYMD(endyear,12,1); Sono un principiante e non riesco a risolvere questo errore: 87 1 of 6 problems AttributeError: type object 'Date' has no attribute 'fromYMD' mi potete aitare passo passo ? Grazie