2. Creating Interactive Maps#

2.1. Introduction#

2.2. Technical requirements#

conda create -n gee python
conda activate gee
conda install -c conda-forge mamba
mamba install -c conda-forge pygis
jupyter lab
# %pip install pygis
import ee
import geemap
geemap.ee_initialize()

2.3. Plotting backends#

2.3.1. Ipyleaflet#

import geemap
Map = geemap.Map()
Map
Map = geemap.Map(center=[40, -100], zoom=4, height=600)
Map
Map = geemap.Map(data_ctrl=False, toolbar_ctrl=False, draw_ctrl=False)
Map
Map = geemap.Map(lite_mode=True)
Map
Map.save('ipyleaflet.html')

2.3.2. Folium#

import geemap.foliumap as geemap
Map = geemap.Map(center=[40, -100], zoom=4, height=600)
Map
Map.save('folium.html')

2.3.3. Plotly#

import geemap.plotlymap as geemap
Map = geemap.Map()
Map
# geemap.fix_widget_error()

2.3.4. Pydeck#

import geemap.deck as geemap
Map = geemap.Map()
Map

2.3.5. KeplerGL#

import geemap.kepler as geemap
Map = geemap.Map()
Map

2.4. Adding basemaps#

2.4.1. Built-in basemaps#

import geemap
Map = geemap.Map(basemap='HYBRID')
Map
Map.add_basemap('OpenTopoMap')
for basemap in geemap.basemaps.keys():
    print(basemap)
len(geemap.basemaps)

2.4.2. XYZ tiles#

Map = geemap.Map()
Map.add_tile_layer(
    url="https://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}",
    name="Google Terrain",
    attribution="Google",
)
Map

2.4.3. WMS tiles#

Map = geemap.Map(center=[40, -100], zoom=4)
url = 'https://www.mrlc.gov/geoserver/mrlc_display/NLCD_2019_Land_Cover_L48/wms?'
Map.add_wms_layer(
    url=url,
    layers='NLCD_2019_Land_Cover_L48',
    name='NLCD 2019',
    format='image/png',
    attribution='MRLC',
    transparent=True,
)
Map

2.4.4. Planet basemaps#

import os

os.environ["PLANET_API_KEY"] = "YOUR_API_KEY"
quarterly_tiles = geemap.planet_quarterly_tiles()
for tile in quarterly_tiles:
    print(tile)
monthly_tiles = geemap.planet_monthly_tiles()
for tile in monthly_tiles:
    print(tile)
Map = geemap.Map()
Map.add_planet_by_month(year=2020, month=8)
Map
Map = geemap.Map()
Map.add_planet_by_quarter(year=2019, quarter=2)
Map

2.4.5. Basemap GUI#

import os

os.environ["PLANET_API_KEY"] = "YOUR_API_KEY"
Map = geemap.Map()
Map

2.5. Summary#