Uncomment the following line to install geemap if needed.
# !pip install geemap
Tutorial 21 - How to export Earth Engine maps as HTML and images
import ee
import geemap
geemap.show_youtube("h0pz3S6Tvx0")
# geemap.update_package()
Map = geemap.Map(toolbar_ctrl=True, layer_ctrl=True)
Map
# Add Earth Engine dataset
dem = ee.Image("USGS/SRTMGL1_003")
landcover = ee.Image("ESA/GLOBCOVER_L4_200901_200912_V2_3").select("landcover")
landsat7 = ee.Image("LANDSAT/LE7_TOA_5YEAR/1999_2003")
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 Map
Map.addLayer(dem, vis_params, "SRTM DEM", True, 0.5)
Map.addLayer(landcover, {}, "Land cover")
Map.addLayer(
landsat7,
{"bands": ["B4", "B3", "B2"], "min": 20, "max": 200, "gamma": 1.5},
"Landsat 7",
)
Map.addLayer(states, {}, "US States")
You can either click the camera icon on toolbar to export maps or use the following script.
import os
download_dir = os.path.join(os.path.expanduser("~"), "Downloads")
if not os.path.exists(download_dir):
os.makedirs(download_dir)
html_file = os.path.join(download_dir, "my_map.html")
Map.to_html(filename=html_file, title="My Map", width="100%", height="880px")
Make sure you click the fullscreen button on the map to maximum the map.
png_file = os.path.join(download_dir, "my_map.png")
Map.to_image(filename=png_file, monitor=1)
jpg_file = os.path.join(download_dir, "my_map.jpg")
Map.to_image(filename=jpg_file, monitor=1)