Introduction to Earth Engine and Geemap
A workshop at Nagoya University, Japan.
Useful links
- Google Earth Engine
- Sign up for an Earth Engine account
- Awesome GEE Community Datasets
- Geemap website
- Geemap book
- Geemap YouTube videos
- Streamlit Web App
Installing geemap¶
Press Ctrl + / to uncomment the following line to install geemap. Restart the kernel/runtime after installation.
In [ ]:
Copied!
# pip install geemap
# pip install geemap
Earth Engine authentication¶
In [ ]:
Copied!
import ee
ee.Authenticate()
import ee
ee.Authenticate()
In [ ]:
Copied!
import geemap
import geemap
In [ ]:
Copied!
Map = geemap.Map()
Map = geemap.Map()
In [ ]:
Copied!
Map
Map
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4, height=600)
Map
Map = geemap.Map(center=[40, -100], zoom=4, height=600)
Map
In [ ]:
Copied!
Map = geemap.Map(data_ctrl=False, toolbar_ctrl=False, draw_ctrl=False)
Map
Map = geemap.Map(data_ctrl=False, toolbar_ctrl=False, draw_ctrl=False)
Map
In [ ]:
Copied!
Map = geemap.Map(lite_mode=True)
Map
Map = geemap.Map(lite_mode=True)
Map
In [ ]:
Copied!
Map.save("ipyleaflet.html")
Map.save("ipyleaflet.html")
In [ ]:
Copied!
import geemap
import geemap
In [ ]:
Copied!
Map = geemap.Map(basemap="HYBRID")
Map
Map = geemap.Map(basemap="HYBRID")
Map
In [ ]:
Copied!
Map.add_basemap("OpenTopoMap")
Map.add_basemap("OpenTopoMap")
In [ ]:
Copied!
for basemap in geemap.basemaps.keys():
print(basemap)
for basemap in geemap.basemaps.keys():
print(basemap)
In [ ]:
Copied!
len(geemap.basemaps)
len(geemap.basemaps)
Basemap GUI¶
In [ ]:
Copied!
Map = geemap.Map()
Map
Map = geemap.Map()
Map
In [ ]:
Copied!
image = ee.Image("USGS/SRTMGL1_003")
image = ee.Image("USGS/SRTMGL1_003")
Visualizing Earth Engine images¶
In [ ]:
Copied!
Map = geemap.Map(center=[21.79, 70.87], zoom=3)
image = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 6000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(image, vis_params, "SRTM")
Map
Map = geemap.Map(center=[21.79, 70.87], zoom=3)
image = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 6000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(image, vis_params, "SRTM")
Map
In [ ]:
Copied!
collection = ee.ImageCollection("COPERNICUS/S2_SR")
collection = ee.ImageCollection("COPERNICUS/S2_SR")
Visualizing image collections¶
In [ ]:
Copied!
Map = geemap.Map()
collection = ee.ImageCollection("COPERNICUS/S2_SR")
image = collection.median()
vis = {
"min": 0.0,
"max": 3000,
"bands": ["B4", "B3", "B2"],
}
Map.setCenter(83.277, 17.7009, 12)
Map.addLayer(image, vis, "Sentinel-2")
Map
Map = geemap.Map()
collection = ee.ImageCollection("COPERNICUS/S2_SR")
image = collection.median()
vis = {
"min": 0.0,
"max": 3000,
"bands": ["B4", "B3", "B2"],
}
Map.setCenter(83.277, 17.7009, 12)
Map.addLayer(image, vis, "Sentinel-2")
Map
Filtering image collections¶
In [ ]:
Copied!
Map = geemap.Map()
collection = (
ee.ImageCollection("COPERNICUS/S2_SR")
.filterDate("2021-01-01", "2022-01-01")
.filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", 5))
)
image = collection.median()
vis = {
"min": 0.0,
"max": 3000,
"bands": ["B4", "B3", "B2"],
}
Map.setCenter(83.277, 17.7009, 12)
Map.addLayer(image, vis, "Sentinel-2")
Map
Map = geemap.Map()
collection = (
ee.ImageCollection("COPERNICUS/S2_SR")
.filterDate("2021-01-01", "2022-01-01")
.filter(ee.Filter.lt("CLOUDY_PIXEL_PERCENTAGE", 5))
)
image = collection.median()
vis = {
"min": 0.0,
"max": 3000,
"bands": ["B4", "B3", "B2"],
}
Map.setCenter(83.277, 17.7009, 12)
Map.addLayer(image, vis, "Sentinel-2")
Map
In [ ]:
Copied!
Map = geemap.Map()
point = ee.Geometry.Point([1.5, 1.5])
lineString = ee.Geometry.LineString([[-35, -10], [35, -10], [35, 10], [-35, 10]])
linearRing = ee.Geometry.LinearRing(
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]
)
rectangle = ee.Geometry.Rectangle([-40, -20, 40, 20])
polygon = ee.Geometry.Polygon([[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]])
Map.addLayer(point, {}, "Point")
Map.addLayer(lineString, {}, "LineString")
Map.addLayer(linearRing, {}, "LinearRing")
Map.addLayer(rectangle, {}, "Rectangle")
Map.addLayer(polygon, {}, "Polygon")
Map
Map = geemap.Map()
point = ee.Geometry.Point([1.5, 1.5])
lineString = ee.Geometry.LineString([[-35, -10], [35, -10], [35, 10], [-35, 10]])
linearRing = ee.Geometry.LinearRing(
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]
)
rectangle = ee.Geometry.Rectangle([-40, -20, 40, 20])
polygon = ee.Geometry.Polygon([[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]])
Map.addLayer(point, {}, "Point")
Map.addLayer(lineString, {}, "LineString")
Map.addLayer(linearRing, {}, "LinearRing")
Map.addLayer(rectangle, {}, "Rectangle")
Map.addLayer(polygon, {}, "Polygon")
Map
In [ ]:
Copied!
Map = geemap.Map()
point = ee.Geometry.Point([1.5, 1.5])
lineString = ee.Geometry.LineString(
[[-35, -10], [35, -10], [35, 10], [-35, 10]], None, False
)
linearRing = ee.Geometry.LinearRing(
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]], None, False
)
rectangle = ee.Geometry.Rectangle([-40, -20, 40, 20], None, False)
polygon = ee.Geometry.Polygon(
[[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]], None, False
)
Map.addLayer(point, {}, "Point")
Map.addLayer(lineString, {}, "LineString")
Map.addLayer(linearRing, {}, "LinearRing")
Map.addLayer(rectangle, {}, "Rectangle")
Map.addLayer(polygon, {}, "Polygon")
Map
Map = geemap.Map()
point = ee.Geometry.Point([1.5, 1.5])
lineString = ee.Geometry.LineString(
[[-35, -10], [35, -10], [35, 10], [-35, 10]], None, False
)
linearRing = ee.Geometry.LinearRing(
[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]], None, False
)
rectangle = ee.Geometry.Rectangle([-40, -20, 40, 20], None, False)
polygon = ee.Geometry.Polygon(
[[[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]], None, False
)
Map.addLayer(point, {}, "Point")
Map.addLayer(lineString, {}, "LineString")
Map.addLayer(linearRing, {}, "LinearRing")
Map.addLayer(rectangle, {}, "Rectangle")
Map.addLayer(polygon, {}, "Polygon")
Map
Using drawing tools¶
In [ ]:
Copied!
if Map.user_roi is not None:
print(Map.user_roi.getInfo())
if Map.user_roi is not None:
print(Map.user_roi.getInfo())
In [ ]:
Copied!
# Create an ee.Geometry.
polygon = ee.Geometry.Polygon(
[[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]], None, False
)
# Create a Feature from the Geometry.
polyFeature = ee.Feature(polygon, {"foo": 42, "bar": "tart"})
# Create an ee.Geometry.
polygon = ee.Geometry.Polygon(
[[[-35, -10], [35, -10], [35, 10], [-35, 10], [-35, -10]]], None, False
)
# Create a Feature from the Geometry.
polyFeature = ee.Feature(polygon, {"foo": 42, "bar": "tart"})
In [ ]:
Copied!
polyFeature.getInfo()
polyFeature.getInfo()
In [ ]:
Copied!
Map = geemap.Map()
Map.addLayer(polyFeature, {}, "feature")
Map
Map = geemap.Map()
Map.addLayer(polyFeature, {}, "feature")
Map
In [ ]:
Copied!
# Create a dictionary of properties, some of which may be computed values.
props = {"foo": ee.Number(8).add(88), "bar": "nihao"}
# Create a None geometry feature with the dictionary of properties.
nowhereFeature = ee.Feature(None, props)
nowhereFeature.getInfo()
# Create a dictionary of properties, some of which may be computed values.
props = {"foo": ee.Number(8).add(88), "bar": "nihao"}
# Create a None geometry feature with the dictionary of properties.
nowhereFeature = ee.Feature(None, props)
nowhereFeature.getInfo()
Setting Feature properties¶
In [ ]:
Copied!
# Make a feature and set some properties.
feature = (
ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]))
.set("genus", "Sequoia")
.set("species", "sempervirens")
)
# Overwrite the old properties with a new dictionary.
newDict = {"genus": "Brachyramphus", "presence": 1, "species": "marmoratus"}
feature = feature.set(newDict)
# Check the result.
feature.getInfo()
# Make a feature and set some properties.
feature = (
ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]))
.set("genus", "Sequoia")
.set("species", "sempervirens")
)
# Overwrite the old properties with a new dictionary.
newDict = {"genus": "Brachyramphus", "presence": 1, "species": "marmoratus"}
feature = feature.set(newDict)
# Check the result.
feature.getInfo()
Getting Feature properties¶
In [ ]:
Copied!
prop = feature.get("species")
prop.getInfo()
prop = feature.get("species")
prop.getInfo()
In [ ]:
Copied!
props = feature.toDictionary()
props.getInfo()
props = feature.toDictionary()
props.getInfo()
In [ ]:
Copied!
Map = geemap.Map()
fc = ee.FeatureCollection("TIGER/2016/Roads")
Map.setCenter(-73.9596, 40.7688, 12)
Map.addLayer(fc, {}, "Census roads")
Map
Map = geemap.Map()
fc = ee.FeatureCollection("TIGER/2016/Roads")
Map.setCenter(-73.9596, 40.7688, 12)
Map.addLayer(fc, {}, "Census roads")
Map
Creating feature collections¶
In [ ]:
Copied!
# Make a list of Features.
features = [
ee.Feature(ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {"name": "Voronoi"}),
ee.Feature(ee.Geometry.Point(-73.96, 40.781), {"name": "Thiessen"}),
ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {"name": "Dirichlet"}),
]
# Create a FeatureCollection from the list and print it.
fromList = ee.FeatureCollection(features)
# Make a list of Features.
features = [
ee.Feature(ee.Geometry.Rectangle(30.01, 59.80, 30.59, 60.15), {"name": "Voronoi"}),
ee.Feature(ee.Geometry.Point(-73.96, 40.781), {"name": "Thiessen"}),
ee.Feature(ee.Geometry.Point(6.4806, 50.8012), {"name": "Dirichlet"}),
]
# Create a FeatureCollection from the list and print it.
fromList = ee.FeatureCollection(features)
In [ ]:
Copied!
fromList.getInfo()
fromList.getInfo()
Filtering feature collections¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
feat = states.filter(ee.Filter.eq("NAME", "Texas"))
Map.addLayer(feat, {}, "Texas")
Map.centerObject(feat)
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
feat = states.filter(ee.Filter.eq("NAME", "Texas"))
Map.addLayer(feat, {}, "Texas")
Map.centerObject(feat)
Map
In [ ]:
Copied!
texas = feat.first()
texas.toDictionary().getInfo()
texas = feat.first()
texas.toDictionary().getInfo()
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
fc = states.filter(ee.Filter.inList("NAME", ["California", "Oregon", "Washington"]))
Map.addLayer(fc, {}, "West Coast")
Map.centerObject(fc)
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
fc = states.filter(ee.Filter.inList("NAME", ["California", "Oregon", "Washington"]))
Map.addLayer(fc, {}, "West Coast")
Map.centerObject(fc)
Map
In [ ]:
Copied!
region = Map.user_roi
if region is None:
region = ee.Geometry.BBox(-88.40, 29.88, -77.90, 35.39)
fc = ee.FeatureCollection("TIGER/2018/States").filterBounds(region)
Map.addLayer(fc, {}, "Southeastern U.S.")
Map.centerObject(fc)
region = Map.user_roi
if region is None:
region = ee.Geometry.BBox(-88.40, 29.88, -77.90, 35.39)
fc = ee.FeatureCollection("TIGER/2018/States").filterBounds(region)
Map.addLayer(fc, {}, "Southeastern U.S.")
Map.centerObject(fc)
Visualizing feature collections¶
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
image = ee.Image().paint(states, 0, 3)
Map.addLayer(image, {"palette": "red"}, "US States")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
image = ee.Image().paint(states, 0, 3)
Map.addLayer(image, {"palette": "red"}, "US States")
Map
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "0000ffff", "width": 2, "lineType": "solid", "fillColor": "FF000080"}
Map.addLayer(states.style(**style), {}, "US States")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "0000ffff", "width": 2, "lineType": "solid", "fillColor": "FF000080"}
Map.addLayer(states.style(**style), {}, "US States")
Map
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"]
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"color": "000000",
"colorOpacity": 1,
"pointSize": 3,
"pointShape": "circle",
"width": 2,
"lineType": "solid",
"fillColorOpacity": 0.66,
}
palette = ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"]
Map.add_styled_vector(
states, column="NAME", palette=palette, layer_name="Styled vector", **vis_params
)
Map
Styling by attribute¶
In [ ]:
Copied!
Map = geemap.Map(center=[28.00142, -81.7424], zoom=13)
Map.add_basemap("HYBRID")
Map = geemap.Map(center=[28.00142, -81.7424], zoom=13)
Map.add_basemap("HYBRID")
In [ ]:
Copied!
types = [
"Freshwater Forested/Shrub Wetland",
"Freshwater Emergent Wetland",
"Freshwater Pond",
"Estuarine and Marine Wetland",
"Riverine",
"Lake",
"Estuarine and Marine Deepwater",
"Other",
]
colors = [
"#008837",
"#7FC31C",
"#688CC0",
"#66C2A5",
"#0190BF",
"#13007C",
"#007C88",
"#B28653",
]
fillColor = [c + "A8" for c in colors]
types = [
"Freshwater Forested/Shrub Wetland",
"Freshwater Emergent Wetland",
"Freshwater Pond",
"Estuarine and Marine Wetland",
"Riverine",
"Lake",
"Estuarine and Marine Deepwater",
"Other",
]
colors = [
"#008837",
"#7FC31C",
"#688CC0",
"#66C2A5",
"#0190BF",
"#13007C",
"#007C88",
"#B28653",
]
fillColor = [c + "A8" for c in colors]
In [ ]:
Copied!
fc = ee.FeatureCollection("projects/sat-io/open-datasets/NWI/wetlands/FL_Wetlands")
styled_fc = geemap.ee_vector_style(
fc, column="WETLAND_TY", labels=types, fillColor=fillColor, color="00000000"
)
fc = ee.FeatureCollection("projects/sat-io/open-datasets/NWI/wetlands/FL_Wetlands")
styled_fc = geemap.ee_vector_style(
fc, column="WETLAND_TY", labels=types, fillColor=fillColor, color="00000000"
)
In [ ]:
Copied!
Map.addLayer(styled_fc, {}, "NWI")
Map.add_legend(title="Wetland Type", labels=types, colors=colors)
Map
Map.addLayer(styled_fc, {}, "NWI")
Map.add_legend(title="Wetland Type", labels=types, colors=colors)
Map
In [ ]:
Copied!
fuels = [
"Coal",
"Oil",
"Gas",
"Hydro",
"Nuclear",
"Solar",
"Waste",
"Wind",
"Geothermal",
"Biomass",
]
colors = [
"000000",
"593704",
"BC80BD",
"0565A6",
"E31A1C",
"FF7F00",
"6A3D9A",
"5CA2D1",
"FDBF6F",
"229A00",
]
fuels = [
"Coal",
"Oil",
"Gas",
"Hydro",
"Nuclear",
"Solar",
"Waste",
"Wind",
"Geothermal",
"Biomass",
]
colors = [
"000000",
"593704",
"BC80BD",
"0565A6",
"E31A1C",
"FF7F00",
"6A3D9A",
"5CA2D1",
"FDBF6F",
"229A00",
]
In [ ]:
Copied!
fc = ee.FeatureCollection("WRI/GPPD/power_plants").filter(
ee.Filter.inList("fuel1", fuels)
)
styled_fc = geemap.ee_vector_style(fc, column="fuel1", labels=fuels, color=colors)
fc = ee.FeatureCollection("WRI/GPPD/power_plants").filter(
ee.Filter.inList("fuel1", fuels)
)
styled_fc = geemap.ee_vector_style(fc, column="fuel1", labels=fuels, color=colors)
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
Map.addLayer(styled_fc, {}, "Power Plants")
Map.add_legend(title="Power Plant Fuel Type", labels=fuels, colors=colors)
Map
Map = geemap.Map(center=[40, -100], zoom=4)
Map.addLayer(styled_fc, {}, "Power Plants")
Map.add_legend(title="Power Plant Fuel Type", labels=fuels, colors=colors)
Map
In [ ]:
Copied!
types = ["I", "U", "S", "M", "C", "O"]
labels = ["Interstate", "U.S.", "State recognized", "Common Name", "County", "Other"]
colors = ["E31A1C", "FF7F00", "6A3D9A", "000000", "FDBF6F", "229A00"]
width = [8, 5, 4, 2, 1, 1]
types = ["I", "U", "S", "M", "C", "O"]
labels = ["Interstate", "U.S.", "State recognized", "Common Name", "County", "Other"]
colors = ["E31A1C", "FF7F00", "6A3D9A", "000000", "FDBF6F", "229A00"]
width = [8, 5, 4, 2, 1, 1]
In [ ]:
Copied!
fc = ee.FeatureCollection("TIGER/2016/Roads")
styled_fc = geemap.ee_vector_style(
fc, column="rttyp", labels=types, color=colors, width=width
)
fc = ee.FeatureCollection("TIGER/2016/Roads")
styled_fc = geemap.ee_vector_style(
fc, column="rttyp", labels=types, color=colors, width=width
)
In [ ]:
Copied!
Map = geemap.Map(center=[40.7424, -73.9724], zoom=13)
Map.addLayer(styled_fc, {}, "Census Roads")
Map.add_legend(title="Route Type", labels=labels, colors=colors)
Map
Map = geemap.Map(center=[40.7424, -73.9724], zoom=13)
Map.addLayer(styled_fc, {}, "Census Roads")
Map.add_legend(title="Route Type", labels=labels, colors=colors)
Map
In [ ]:
Copied!
dataset_xyz = ee.Image("USGS/SRTMGL1_003")
Map.addLayer(dataset_xyz, {}, "USGS/SRTMGL1_003")
dataset_xyz = ee.Image("USGS/SRTMGL1_003")
Map.addLayer(dataset_xyz, {}, "USGS/SRTMGL1_003")
In [ ]:
Copied!
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
Using the datasets module¶
In [ ]:
Copied!
from geemap.datasets import DATA
from geemap.datasets import DATA
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
dataset = ee.Image(DATA.USGS_GAP_CONUS_2011)
Map.addLayer(dataset, {}, "GAP CONUS")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
dataset = ee.Image(DATA.USGS_GAP_CONUS_2011)
Map.addLayer(dataset, {}, "GAP CONUS")
Map
In [ ]:
Copied!
from geemap.datasets import get_metadata
get_metadata(DATA.USGS_GAP_CONUS_2011)
from geemap.datasets import get_metadata
get_metadata(DATA.USGS_GAP_CONUS_2011)
Getting image metadata¶
In [ ]:
Copied!
image = ee.Image("LANDSAT/LC09/C02/T1_L2/LC09_044034_20220503")
image = ee.Image("LANDSAT/LC09/C02/T1_L2/LC09_044034_20220503")
In [ ]:
Copied!
image.bandNames().getInfo()
image.bandNames().getInfo()
In [ ]:
Copied!
image.select("SR_B1").projection().getInfo()
image.select("SR_B1").projection().getInfo()
In [ ]:
Copied!
image.select("SR_B1").projection().nominalScale().getInfo()
image.select("SR_B1").projection().nominalScale().getInfo()
In [ ]:
Copied!
image.propertyNames().getInfo()
image.propertyNames().getInfo()
In [ ]:
Copied!
image.get("CLOUD_COVER").getInfo()
image.get("CLOUD_COVER").getInfo()
In [ ]:
Copied!
image.get("DATE_ACQUIRED").getInfo()
image.get("DATE_ACQUIRED").getInfo()
In [ ]:
Copied!
image.get("system:time_start").getInfo()
image.get("system:time_start").getInfo()
In [ ]:
Copied!
date = ee.Date(image.get("system:time_start"))
date.format("YYYY-MM-dd").getInfo()
date = ee.Date(image.get("system:time_start"))
date.format("YYYY-MM-dd").getInfo()
In [ ]:
Copied!
image.toDictionary().getInfo()
image.toDictionary().getInfo()
In [ ]:
Copied!
props = geemap.image_props(image)
props.getInfo()
props = geemap.image_props(image)
props.getInfo()
Calculating descriptive statistics¶
In [ ]:
Copied!
image = ee.Image("LANDSAT/LC09/C02/T1_L2/LC09_044034_20220503")
geemap.image_min_value(image).getInfo()
image = ee.Image("LANDSAT/LC09/C02/T1_L2/LC09_044034_20220503")
geemap.image_min_value(image).getInfo()
In [ ]:
Copied!
geemap.image_max_value(image).getInfo()
geemap.image_max_value(image).getInfo()
In [ ]:
Copied!
geemap.image_mean_value(image).getInfo()
geemap.image_mean_value(image).getInfo()
In [ ]:
Copied!
geemap.image_stats(image).getInfo()
geemap.image_stats(image).getInfo()
Using the inspector tool¶
In [ ]:
Copied!
# Create an interactive map
Map = geemap.Map(center=(40, -100), zoom=4)
# Add Earth Engine datasets
dem = ee.Image("USGS/SRTMGL1_003")
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
["B1", "B2", "B3", "B4", "B5", "B7"]
)
states = ee.FeatureCollection("TIGER/2018/States")
# Set visualization parameters.
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
# Add Earth Engine layers to the map
Map.addLayer(dem, vis_params, "SRTM DEM")
Map.addLayer(
landsat7,
{"bands": ["B4", "B3", "B2"], "min": 20, "max": 200, "gamma": 2.0},
"Landsat 7",
)
Map.addLayer(states, {}, "US States")
# Display the map
Map
# Create an interactive map
Map = geemap.Map(center=(40, -100), zoom=4)
# Add Earth Engine datasets
dem = ee.Image("USGS/SRTMGL1_003")
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
["B1", "B2", "B3", "B4", "B5", "B7"]
)
states = ee.FeatureCollection("TIGER/2018/States")
# Set visualization parameters.
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
# Add Earth Engine layers to the map
Map.addLayer(dem, vis_params, "SRTM DEM")
Map.addLayer(
landsat7,
{"bands": ["B4", "B3", "B2"], "min": 20, "max": 200, "gamma": 2.0},
"Landsat 7",
)
Map.addLayer(states, {}, "US States")
# Display the map
Map
Using the plotting tool¶
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
["B1", "B2", "B3", "B4", "B5", "B7"]
)
landsat_vis = {"bands": ["B4", "B3", "B2"], "gamma": 1.4}
Map.addLayer(landsat7, landsat_vis, "Landsat")
hyperion = ee.ImageCollection("EO1/HYPERION").filter(
ee.Filter.date("2016-01-01", "2017-03-01")
)
hyperion_vis = {
"min": 1000.0,
"max": 14000.0,
"gamma": 2.5,
}
Map.addLayer(hyperion, hyperion_vis, "Hyperion")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003").select(
["B1", "B2", "B3", "B4", "B5", "B7"]
)
landsat_vis = {"bands": ["B4", "B3", "B2"], "gamma": 1.4}
Map.addLayer(landsat7, landsat_vis, "Landsat")
hyperion = ee.ImageCollection("EO1/HYPERION").filter(
ee.Filter.date("2016-01-01", "2017-03-01")
)
hyperion_vis = {
"min": 1000.0,
"max": 14000.0,
"gamma": 2.5,
}
Map.addLayer(hyperion, hyperion_vis, "Hyperion")
Map
In [ ]:
Copied!
Map.set_plot_options(add_marker_cluster=True, overlay=True)
Map.set_plot_options(add_marker_cluster=True, overlay=True)
Changing layer opacity¶
In [ ]:
Copied!
Map = geemap.Map(center=(40, -100), zoom=4)
dem = ee.Image("USGS/SRTMGL1_003")
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM", True, 1)
Map.addLayer(states, {}, "US States", True)
Map
Map = geemap.Map(center=(40, -100), zoom=4)
dem = ee.Image("USGS/SRTMGL1_003")
states = ee.FeatureCollection("TIGER/2018/States")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM", True, 1)
Map.addLayer(states, {}, "US States", True)
Map
In [ ]:
Copied!
Map = geemap.Map(center=[12, 69], zoom=3)
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
Map = geemap.Map(center=[12, 69], zoom=3)
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
In [ ]:
Copied!
vis_params = {
"bands": ["elevation"],
"palette": ["333399", " 00b2b2", " 99eb85", " ccbe7d", " 997c76", " ffffff"],
"min": 0.0,
"max": 6000.0,
"opacity": 1.0,
"gamma": 1.0,
}
vis_params = {
"bands": ["elevation"],
"palette": ["333399", " 00b2b2", " 99eb85", " ccbe7d", " 997c76", " ffffff"],
"min": 0.0,
"max": 6000.0,
"opacity": 1.0,
"gamma": 1.0,
}
Multi-band images¶
In [ ]:
Copied!
Map = geemap.Map()
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003")
vis_params = {
"min": 20,
"max": 200,
"gamma": 2,
"bands": ["B4", "B3", "B2"],
}
Map.addLayer(landsat7, vis_params, "Landsat 7")
Map
Map = geemap.Map()
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003")
vis_params = {
"min": 20,
"max": 200,
"gamma": 2,
"bands": ["B4", "B3", "B2"],
}
Map.addLayer(landsat7, vis_params, "Landsat 7")
Map
Visualizing vector data¶
In [ ]:
Copied!
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
Map = geemap.Map()
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states, {}, "US States")
Map
In [ ]:
Copied!
vis_params = {
"color": "ff0000ff",
"width": 2,
"lineType": "solid",
"fillColor": "00000000",
}
vis_params = {
"color": "ff0000ff",
"width": 2,
"lineType": "solid",
"fillColor": "00000000",
}
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states.style(**vis_params), {}, "US States")
Map
Map = geemap.Map(center=[40, -100], zoom=4)
states = ee.FeatureCollection("TIGER/2018/States")
Map.addLayer(states.style(**vis_params), {}, "US States")
Map
In [ ]:
Copied!
legends = geemap.builtin_legends
for legend in legends:
print(legend)
legends = geemap.builtin_legends
for legend in legends:
print(legend)
In [ ]:
Copied!
Map.add_legend(builtin_legend="NLCD")
Map.add_legend(builtin_legend="NLCD")
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
Map.add_basemap("HYBRID")
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019")
landcover = nlcd.select("landcover")
Map.addLayer(landcover, {}, "NLCD Land Cover 2019")
Map.add_legend(
title="NLCD Land Cover Classification", builtin_legend="NLCD", height="465px"
)
Map
Map = geemap.Map(center=[40, -100], zoom=4)
Map.add_basemap("HYBRID")
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019")
landcover = nlcd.select("landcover")
Map.addLayer(landcover, {}, "NLCD Land Cover 2019")
Map.add_legend(
title="NLCD Land Cover Classification", builtin_legend="NLCD", height="465px"
)
Map
Custom legends¶
In [ ]:
Copied!
Map = geemap.Map(add_google_map=False)
labels = ["One", "Two", "Three", "Four", "etc"]
# colors can be defined using either hex code or RGB (0-255, 0-255, 0-255)
colors = ["#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3"]
# legend_colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68 123)]
Map.add_legend(labels=labels, colors=colors, position="bottomright")
Map
Map = geemap.Map(add_google_map=False)
labels = ["One", "Two", "Three", "Four", "etc"]
# colors can be defined using either hex code or RGB (0-255, 0-255, 0-255)
colors = ["#8DD3C7", "#FFFFB3", "#BEBADA", "#FB8072", "#80B1D3"]
# legend_colors = [(255, 0, 0), (127, 255, 0), (127, 18, 25), (36, 70, 180), (96, 68 123)]
Map.add_legend(labels=labels, colors=colors, position="bottomright")
Map
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
legend_dict = {
"11 Open Water": "466b9f",
"12 Perennial Ice/Snow": "d1def8",
"21 Developed, Open Space": "dec5c5",
"22 Developed, Low Intensity": "d99282",
"23 Developed, Medium Intensity": "eb0000",
"24 Developed High Intensity": "ab0000",
"31 Barren Land (Rock/Sand/Clay)": "b3ac9f",
"41 Deciduous Forest": "68ab5f",
"42 Evergreen Forest": "1c5f2c",
"43 Mixed Forest": "b5c58f",
"51 Dwarf Scrub": "af963c",
"52 Shrub/Scrub": "ccb879",
"71 Grassland/Herbaceous": "dfdfc2",
"72 Sedge/Herbaceous": "d1d182",
"73 Lichens": "a3cc51",
"74 Moss": "82ba9e",
"81 Pasture/Hay": "dcd939",
"82 Cultivated Crops": "ab6c28",
"90 Woody Wetlands": "b8d9eb",
"95 Emergent Herbaceous Wetlands": "6c9fb8",
}
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019")
landcover = nlcd.select("landcover")
Map.addLayer(landcover, {}, "NLCD Land Cover 2019")
Map.add_legend(title="NLCD Land Cover Classification", legend_dict=legend_dict)
Map
Map = geemap.Map(center=[40, -100], zoom=4)
legend_dict = {
"11 Open Water": "466b9f",
"12 Perennial Ice/Snow": "d1def8",
"21 Developed, Open Space": "dec5c5",
"22 Developed, Low Intensity": "d99282",
"23 Developed, Medium Intensity": "eb0000",
"24 Developed High Intensity": "ab0000",
"31 Barren Land (Rock/Sand/Clay)": "b3ac9f",
"41 Deciduous Forest": "68ab5f",
"42 Evergreen Forest": "1c5f2c",
"43 Mixed Forest": "b5c58f",
"51 Dwarf Scrub": "af963c",
"52 Shrub/Scrub": "ccb879",
"71 Grassland/Herbaceous": "dfdfc2",
"72 Sedge/Herbaceous": "d1d182",
"73 Lichens": "a3cc51",
"74 Moss": "82ba9e",
"81 Pasture/Hay": "dcd939",
"82 Cultivated Crops": "ab6c28",
"90 Woody Wetlands": "b8d9eb",
"95 Emergent Herbaceous Wetlands": "6c9fb8",
}
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019")
landcover = nlcd.select("landcover")
Map.addLayer(landcover, {}, "NLCD Land Cover 2019")
Map.add_legend(title="NLCD Land Cover Classification", legend_dict=legend_dict)
Map
Creating color bars¶
In [ ]:
Copied!
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
vis_params = {
"min": 0,
"max": 4000,
"palette": ["006633", "E5FFCC", "662A00", "D8D8D8", "F5F5F5"],
}
Map.addLayer(dem, vis_params, "SRTM DEM")
Map
In [ ]:
Copied!
Map.add_colorbar(vis_params, label="Elevation (m)", layer_name="SRTM DEM")
Map.add_colorbar(vis_params, label="Elevation (m)", layer_name="SRTM DEM")
In [ ]:
Copied!
Map.add_colorbar(
vis_params, label="Elevation (m)", layer_name="SRTM DEM", orientation="vertical"
)
Map.add_colorbar(
vis_params, label="Elevation (m)", layer_name="SRTM DEM", orientation="vertical"
)
In [ ]:
Copied!
Map.add_colorbar(
vis_params,
label="Elevation (m)",
layer_name="SRTM DEM",
orientation="vertical",
transparent_bg=True,
)
Map.add_colorbar(
vis_params,
label="Elevation (m)",
layer_name="SRTM DEM",
orientation="vertical",
transparent_bg=True,
)
Displaying labels¶
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4, add_google_map=False)
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "black", "fillColor": "00000000"}
Map.addLayer(states.style(**style), {}, "US States")
Map
Map = geemap.Map(center=[40, -100], zoom=4, add_google_map=False)
states = ee.FeatureCollection("TIGER/2018/States")
style = {"color": "black", "fillColor": "00000000"}
Map.addLayer(states.style(**style), {}, "US States")
Map
In [ ]:
Copied!
Map.add_labels(
data=states,
column="STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
draggable=True,
)
Map.add_labels(
data=states,
column="STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
draggable=True,
)
In [ ]:
Copied!
Map.remove_labels()
Map.remove_labels()
In [ ]:
Copied!
centroids = geemap.vector_centroids(states)
df = geemap.ee_to_df(centroids)
df
centroids = geemap.vector_centroids(states)
df = geemap.ee_to_df(centroids)
df
In [ ]:
Copied!
Map.add_labels(
data=df,
column="STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
x="longitude",
y="latitude",
)
Map
Map.add_labels(
data=df,
column="STUSPS",
font_size="12pt",
font_color="blue",
font_family="arial",
font_weight="bold",
x="longitude",
y="latitude",
)
Map
Split-panel maps¶
In [ ]:
Copied!
Map = geemap.Map()
Map.split_map(left_layer="HYBRID", right_layer="TERRAIN")
Map
Map = geemap.Map()
Map.split_map(left_layer="HYBRID", right_layer="TERRAIN")
Map
In [ ]:
Copied!
Map = geemap.Map(center=(40, -100), zoom=4, height=600)
nlcd_2001 = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2001").select("landcover")
nlcd_2019 = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019").select("landcover")
left_layer = geemap.ee_tile_layer(nlcd_2001, {}, "NLCD 2001")
right_layer = geemap.ee_tile_layer(nlcd_2019, {}, "NLCD 2019")
Map.split_map(left_layer, right_layer)
Map
Map = geemap.Map(center=(40, -100), zoom=4, height=600)
nlcd_2001 = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2001").select("landcover")
nlcd_2019 = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019").select("landcover")
left_layer = geemap.ee_tile_layer(nlcd_2001, {}, "NLCD 2001")
right_layer = geemap.ee_tile_layer(nlcd_2019, {}, "NLCD 2019")
Map.split_map(left_layer, right_layer)
Map
Linked maps¶
In [ ]:
Copied!
image = (
ee.ImageCollection("COPERNICUS/S2")
.filterDate("2018-09-01", "2018-09-30")
.map(lambda img: img.divide(10000))
.median()
)
vis_params = [
{"bands": ["B4", "B3", "B2"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B8", "B11", "B4"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B8", "B4", "B3"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B12", "B12", "B4"], "min": 0, "max": 0.3, "gamma": 1.3},
]
labels = [
"Natural Color (B4/B3/B2)",
"Land/Water (B8/B11/B4)",
"Color Infrared (B8/B4/B3)",
"Vegetation (B12/B11/B4)",
]
geemap.linked_maps(
rows=2,
cols=2,
height="300px",
center=[38.4151, 21.2712],
zoom=12,
ee_objects=[image],
vis_params=vis_params,
labels=labels,
label_position="topright",
)
image = (
ee.ImageCollection("COPERNICUS/S2")
.filterDate("2018-09-01", "2018-09-30")
.map(lambda img: img.divide(10000))
.median()
)
vis_params = [
{"bands": ["B4", "B3", "B2"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B8", "B11", "B4"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B8", "B4", "B3"], "min": 0, "max": 0.3, "gamma": 1.3},
{"bands": ["B12", "B12", "B4"], "min": 0, "max": 0.3, "gamma": 1.3},
]
labels = [
"Natural Color (B4/B3/B2)",
"Land/Water (B8/B11/B4)",
"Color Infrared (B8/B4/B3)",
"Vegetation (B12/B11/B4)",
]
geemap.linked_maps(
rows=2,
cols=2,
height="300px",
center=[38.4151, 21.2712],
zoom=12,
ee_objects=[image],
vis_params=vis_params,
labels=labels,
label_position="topright",
)
In [ ]:
Copied!
Map = geemap.Map(center=[40, -100], zoom=4)
collection = ee.ImageCollection("USGS/NLCD_RELEASES/2019_REL/NLCD").select("landcover")
vis_params = {"bands": ["landcover"]}
years = collection.aggregate_array("system:index").getInfo()
years
Map = geemap.Map(center=[40, -100], zoom=4)
collection = ee.ImageCollection("USGS/NLCD_RELEASES/2019_REL/NLCD").select("landcover")
vis_params = {"bands": ["landcover"]}
years = collection.aggregate_array("system:index").getInfo()
years
In [ ]:
Copied!
Map.ts_inspector(
left_ts=collection,
right_ts=collection,
left_names=years,
right_names=years,
left_vis=vis_params,
right_vis=vis_params,
width="80px",
)
Map
Map.ts_inspector(
left_ts=collection,
right_ts=collection,
left_names=years,
right_names=years,
left_vis=vis_params,
right_vis=vis_params,
width="80px",
)
Map
In [ ]:
Copied!
Map = geemap.Map()
collection = (
ee.ImageCollection("MODIS/MCD43A4_006_NDVI")
.filter(ee.Filter.date("2018-06-01", "2018-07-01"))
.select("NDVI")
)
vis_params = {
"min": 0.0,
"max": 1.0,
"palette": [
"FFFFFF",
"CE7E45",
"DF923D",
"F1B555",
"FCD163",
"99B718",
"74A901",
"66A000",
"529400",
"3E8601",
"207401",
"056201",
"004C00",
"023B01",
"012E01",
"011D01",
"011301",
],
}
Map.add_time_slider(collection, vis_params, time_interval=2)
Map
Map = geemap.Map()
collection = (
ee.ImageCollection("MODIS/MCD43A4_006_NDVI")
.filter(ee.Filter.date("2018-06-01", "2018-07-01"))
.select("NDVI")
)
vis_params = {
"min": 0.0,
"max": 1.0,
"palette": [
"FFFFFF",
"CE7E45",
"DF923D",
"F1B555",
"FCD163",
"99B718",
"74A901",
"66A000",
"529400",
"3E8601",
"207401",
"056201",
"004C00",
"023B01",
"012E01",
"011D01",
"011301",
],
}
Map.add_time_slider(collection, vis_params, time_interval=2)
Map
Visualizing weather data¶
In [ ]:
Copied!
Map = geemap.Map()
collection = (
ee.ImageCollection("NOAA/GFS0P25")
.filterDate("2018-12-22", "2018-12-23")
.limit(24)
.select("temperature_2m_above_ground")
)
vis_params = {
"min": -40.0,
"max": 35.0,
"palette": ["blue", "purple", "cyan", "green", "yellow", "red"],
}
labels = [str(n).zfill(2) + ":00" for n in range(0, 24)]
Map.add_time_slider(collection, vis_params, labels=labels, time_interval=1, opacity=0.8)
Map
Map = geemap.Map()
collection = (
ee.ImageCollection("NOAA/GFS0P25")
.filterDate("2018-12-22", "2018-12-23")
.limit(24)
.select("temperature_2m_above_ground")
)
vis_params = {
"min": -40.0,
"max": 35.0,
"palette": ["blue", "purple", "cyan", "green", "yellow", "red"],
}
labels = [str(n).zfill(2) + ":00" for n in range(0, 24)]
Map.add_time_slider(collection, vis_params, labels=labels, time_interval=1, opacity=0.8)
Map
Visualizing Sentinel-2 imagery¶
In [ ]:
Copied!
Map = geemap.Map(center=[37.75, -122.45], zoom=12)
collection = (
ee.ImageCollection("COPERNICUS/S2_SR")
.filterBounds(ee.Geometry.Point([-122.45, 37.75]))
.filterMetadata("CLOUDY_PIXEL_PERCENTAGE", "less_than", 10)
)
vis_params = {"min": 0, "max": 4000, "bands": ["B8", "B4", "B3"]}
Map.add_time_slider(collection, vis_params)
Map
Map = geemap.Map(center=[37.75, -122.45], zoom=12)
collection = (
ee.ImageCollection("COPERNICUS/S2_SR")
.filterBounds(ee.Geometry.Point([-122.45, 37.75]))
.filterMetadata("CLOUDY_PIXEL_PERCENTAGE", "less_than", 10)
)
vis_params = {"min": 0, "max": 4000, "bands": ["B8", "B4", "B3"]}
Map.add_time_slider(collection, vis_params)
Map
Shaded relief maps¶
In [ ]:
Copied!
import geemap.colormaps as cm
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(dem)
vis = {"min": 0, "max": 6000, "palette": cm.palettes.terrain}
blend = geemap.blend(top_layer=dem, top_vis=vis)
Map.addLayer(hillshade, {}, "Hillshade")
Map.addLayer(blend, {}, "Shaded relief")
Map.add_colorbar(vis, label="Elevation (m)")
Map.setCenter(91.4206, 27.3225, zoom=9)
Map
import geemap.colormaps as cm
Map = geemap.Map()
dem = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(dem)
vis = {"min": 0, "max": 6000, "palette": cm.palettes.terrain}
blend = geemap.blend(top_layer=dem, top_vis=vis)
Map.addLayer(hillshade, {}, "Hillshade")
Map.addLayer(blend, {}, "Shaded relief")
Map.add_colorbar(vis, label="Elevation (m)")
Map.setCenter(91.4206, 27.3225, zoom=9)
Map
In [ ]:
Copied!
left_layer = geemap.ee_tile_layer(blend, {}, "Shaded relief")
right_layer = geemap.ee_tile_layer(hillshade, {}, "Hillshade")
Map.split_map(left_layer, right_layer)
left_layer = geemap.ee_tile_layer(blend, {}, "Shaded relief")
right_layer = geemap.ee_tile_layer(hillshade, {}, "Hillshade")
Map.split_map(left_layer, right_layer)
In [ ]:
Copied!
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019").select("landcover")
nlcd_vis = {"bands": ["landcover"]}
blend = geemap.blend(nlcd, dem, top_vis=nlcd_vis, expression="a*b")
Map.addLayer(blend, {}, "Blend NLCD")
Map.add_legend(builtin_legend="NLCD", title="NLCD Land Cover")
Map.setCenter(-118.1310, 35.6816, 10)
nlcd = ee.Image("USGS/NLCD_RELEASES/2019_REL/NLCD/2019").select("landcover")
nlcd_vis = {"bands": ["landcover"]}
blend = geemap.blend(nlcd, dem, top_vis=nlcd_vis, expression="a*b")
Map.addLayer(blend, {}, "Blend NLCD")
Map.add_legend(builtin_legend="NLCD", title="NLCD Land Cover")
Map.setCenter(-118.1310, 35.6816, 10)
Elevation contours¶
In [ ]:
Copied!
import geemap.colormaps as cm
import geemap.colormaps as cm
In [ ]:
Copied!
Map = geemap.Map()
image = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(image)
Map.addLayer(hillshade, {}, "Hillshade")
Map
Map = geemap.Map()
image = ee.Image("USGS/SRTMGL1_003")
hillshade = ee.Terrain.hillshade(image)
Map.addLayer(hillshade, {}, "Hillshade")
Map
In [ ]:
Copied!
vis_params = {"min": 0, "max": 5000, "palette": cm.palettes.dem}
Map.addLayer(image, vis_params, "dem", True, 0.5)
Map.add_colorbar(vis_params, label="Elevation (m)")
vis_params = {"min": 0, "max": 5000, "palette": cm.palettes.dem}
Map.addLayer(image, vis_params, "dem", True, 0.5)
Map.add_colorbar(vis_params, label="Elevation (m)")
In [ ]:
Copied!
contours = geemap.create_contours(image, 0, 5000, 100, region=None)
Map.addLayer(contours, {"palette": "black"}, "contours")
Map.setCenter(-119.3678, 37.1671, 12)
contours = geemap.create_contours(image, 0, 5000, 100, region=None)
Map.addLayer(contours, {"palette": "black"}, "contours")
Map.setCenter(-119.3678, 37.1671, 12)
Image descriptive statistics¶
In [ ]:
Copied!
Map = geemap.Map()
centroid = ee.Geometry.Point([-122.4439, 37.7538])
image = ee.ImageCollection