05 drawing tools
Uncomment the following line to install geemap if needed.
In [1]:
Copied!
# !pip install geemap
# !pip install geemap
In [2]:
Copied!
import ee
import geemap
import ee
import geemap
In [3]:
Copied!
geemap.show_youtube('N7rK2aV1R4c')
geemap.show_youtube('N7rK2aV1R4c')
In [4]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
Out[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [5]:
Copied!
# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')
# Set visualization parameters.
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
# Add Earth Engine DEM to map
Map.addLayer(image, vis_params, 'SRTM DEM')
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, 'US States')
# Add Earth Engine dataset
image = ee.Image('USGS/SRTMGL1_003')
# Set visualization parameters.
vis_params = {
'min': 0,
'max': 4000,
'palette': ['006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5'],
}
# Add Earth Engine DEM to map
Map.addLayer(image, vis_params, 'SRTM DEM')
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, 'US States')
In [6]:
Copied!
Map.draw_features
Map.draw_features
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [6], in <cell line: 1>() ----> 1 Map.draw_features AttributeError: 'Map' object has no attribute 'draw_features'
In [7]:
Copied!
Map.draw_last_feature
Map.draw_last_feature
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [7], in <cell line: 1>() ----> 1 Map.draw_last_feature AttributeError: 'Map' object has no attribute 'draw_last_feature'
In [8]:
Copied!
roi = ee.FeatureCollection(Map.draw_features)
selected_states = states.filterBounds(roi)
Map.addLayer(selected_states, {}, "Selected states")
roi = ee.FeatureCollection(Map.draw_features)
selected_states = states.filterBounds(roi)
Map.addLayer(selected_states, {}, "Selected states")
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [8], in <cell line: 1>() ----> 1 roi = ee.FeatureCollection(Map.draw_features) 2 selected_states = states.filterBounds(roi) 3 Map.addLayer(selected_states, {}, "Selected states") AttributeError: 'Map' object has no attribute 'draw_features'
In [9]:
Copied!
clipped_image = image.clip(selected_states)
Map.addLayer(clipped_image, vis_params, 'Clipped image')
clipped_image = image.clip(selected_states)
Map.addLayer(clipped_image, vis_params, 'Clipped image')
--------------------------------------------------------------------------- NameError Traceback (most recent call last) Input In [9], in <cell line: 1>() ----> 1 clipped_image = image.clip(selected_states) 2 Map.addLayer(clipped_image, vis_params, 'Clipped image') NameError: name 'selected_states' is not defined
Last update:
2022-03-14