03 creating maps
Introduction¶
Geemap has six plotting backends, including folium, ipyleaflet, plotly, pydeck, kepler.gl, and heremap. An interactive map created using one of the plotting backends can be displayed in a Jupyter environment, such as Google Colab, Jupyter Notebook, and JupyterLab. By default, import leafmap
will use the ipyleaflet
plotting backend.
The six plotting backends do not offer equal functionality. The ipyleaflet
plotting backend provides the richest interactive functionality, including the custom toolset for loading, analyzing, and visualizing geospatial data interactively without coding. For example, users can add vector data (e.g., GeoJSON, Shapefile, KML, GeoDataFrame) and raster data (e.g., GeoTIFF, Cloud Optimized GeoTIFF [COG]) to the map with a few clicks (see Figure 1). Users can also perform geospatial analysis using the WhiteboxTools GUI with 468 geoprocessing tools directly within the map interface (see Figure 2). Other interactive functionality (e.g., split-panel map, linked map, time slider, time-series inspector) can also be useful for visualizing geospatial data. The ipyleaflet
package is built upon ipywidgets
and allows bidirectional communication between the front-end and the backend enabling the use of the map to capture user input (source). In contrast, folium
has relatively limited interactive functionality. It is meant for displaying static data only. Note that the aforementioned custom toolset and interactive functionality are not available for other plotting backends. Compared with ipyleaflet
and folium
, the pydeck
, kepler.gl
, and heremap
plotting backend provides some unique 3D mapping functionality. An API key from the Here Developer Portal is required to use heremap
.
To choose a specific plotting backend, use one of the following:
import leafmap.leafmap as leafmap
import leafmap.foliumap as leafmap
import leafmap.deck as leafmap
import leafmap.kepler as leafmap
import leafmap.plotlymap as leafmap
import leafmap.heremap as leafmap
Uncomment and execute the following code block to install geemap if needed.
# !pip install geemap
The ipyleaflet plotting backend¶
You can simply use geemap.Map()
to create the default map.
import geemap
Map = geemap.Map()
Map
To customize the map, you can specify various parameters, such as center
([lat, lon]), zoom
, width
, and height
.
Map = geemap.Map(center=[40, -100], zoom=4, height=600)
Map
You can also set the visibility of the controls, such as data_ctrl
, zoom_ctrl
, fullscreen_ctrl
, draw_ctrl
, measure_ctrl
, scale_ctrl
, layer_ctrl
, toolbar_ctrl
, and attribution_ctrl
. You can also set lite_mode=True
to only show the Zoom Control.
Map = geemap.Map(data_ctrl=False, toolbar_ctrl=False, draw_ctrl=False)
Map
Map = geemap.Map(lite_mode=True)
Map
The folium plotting backend¶
import geemap.foliumap as geemap
Map = geemap.Map(height=600)
Map
The plotly plotting backend¶
import geemap.plotlymap as geemap
Map = geemap.Map()
Map
The pydeck plotting backend¶
import geemap.deck as geemap
Map = geemap.Map()
Map
The kerler.gl plotting backend¶
import geemap.kepler as geemap
Map = geemap.Map()
Map
The heremap plotting backend¶
An API key from the Here Developer Portal is required to use heremap
.
import os
import geemap.heremap as geemap
api_key = os.environ.get(
'HEREMAPS_API_KEY'
) # Provide your Heremap API key here if it is not set as an environment variable.
Map = geemap.Map(api_key)
Map