A Python package for interactive geospatial analysis and visualization with Google Earth Engine
npx @tessl/cli install tessl/pypi-geemap@0.36.0A comprehensive Python package for interactive geospatial analysis and visualization with Google Earth Engine (GEE). Geemap bridges the gap between GEE's JavaScript API and Python's scientific computing ecosystem, providing interactive mapping capabilities within Jupyter environments and supporting multiple mapping backends (ipyleaflet, folium, plotly, kepler.gl, pydeck, maplibre).
pip install geemapimport geemapFor working with maps:
# Main Map class (backend depends on USE_FOLIUM environment variable)
from geemap import Map
# Specific backend imports if needed
from geemap.geemap import Map as IPyLeafletMap # ipyleaflet backend
from geemap.foliumap import Map as FoliumMap # folium backendimport geemap
import ee
# Initialize Earth Engine
ee.Initialize()
# Create an interactive map
m = geemap.Map(center=[40, -100], zoom=4)
# Add Earth Engine data
dataset = ee.ImageCollection('USDA/NAIP/DOQQ')
trueColorVis = {
'min': 0,
'max': 255,
'bands': ['R', 'G', 'B']
}
m.addLayer(dataset, trueColorVis, 'True Color')
# Display the map
mGeemap uses a modular architecture with conditional imports:
USE_FOLIUM environment variableCore mapping functionality with multiple backend support, providing interactive visualization capabilities for geospatial data with Earth Engine integration.
class Map:
def __init__(self, **kwargs) -> None:
"""
Initialize the map with given keyword arguments.
Args:
**kwargs: Additional keyword arguments for the map including:
center (list, optional): Center of the map (lat, lon). Defaults to [0, 0].
zoom (int, optional): Zoom level of the map. Defaults to 2.
height (str, optional): Height of the map. Defaults to "600px".
width (str, optional): Width of the map. Defaults to "100%".
basemap: Basemap to use. Defaults to first available basemap.
"""
def add_layer(self, ee_object, vis_params=None, name=None, shown=True, opacity=1.0):
"""
Adds a layer to the map.
Args:
ee_object: The Earth Engine object to add as a layer.
vis_params (dict, optional): Visualization parameters. Defaults to None.
name (str, optional): Name of the layer. Defaults to None.
shown (bool, optional): Whether the layer is shown. Defaults to True.
opacity (float, optional): Opacity of the layer. Defaults to 1.0.
"""
def center_object(self, ee_object, zoom=None):
"""
Centers the map on an Earth Engine object.
Args:
ee_object: The Earth Engine object to center on.
zoom (int, optional): Zoom level. Defaults to None.
"""
def set_center(self, lon, lat, zoom=None):
"""
Sets the center and zoom of the map.
Args:
lon (float): Longitude of the center.
lat (float): Latitude of the center.
zoom (int, optional): Zoom level. Defaults to None.
"""
# Aliases for Earth Engine JavaScript API compatibility
addLayer = add_layer
centerObject = center_object
setCenter = set_centerComprehensive data export capabilities for Earth Engine assets to various formats and storage destinations including Google Drive, Cloud Storage, and local files.
def ee_export_image(ee_object, filename, scale=None, crs=None, crs_transform=None,
region=None, dimensions=None, file_per_band=False,
format="ZIPPED_GEO_TIFF", unzip=True, unmask_value=None,
timeout=300, proxies=None, verbose=True):
"""
Exports an ee.Image as a GeoTIFF.
Args:
ee_object: The ee.Image to download.
filename (str): Output filename for the exported image.
scale (float, optional): Default scale for bands. Defaults to None.
crs (str, optional): Default CRS string. Defaults to None.
crs_transform (list, optional): Default affine transform. Defaults to None.
region: Polygon specifying region to download. Defaults to None.
dimensions (list, optional): Width and height for cropping. Defaults to None.
file_per_band (bool, optional): Produce different GeoTIFF per band. Defaults to False.
format (str, optional): Export format. Defaults to "ZIPPED_GEO_TIFF".
unzip (bool, optional): Whether to unzip downloaded file. Defaults to True.
unmask_value (float, optional): Value for masked pixels. Defaults to None.
timeout (int, optional): Request timeout in seconds. Defaults to 300.
proxies (dict, optional): Proxy servers to use. Defaults to None.
verbose (bool, optional): Whether to print descriptive text. Defaults to True.
"""
def ee_export_image_to_drive(image, description="myExportImageTask", folder=None,
fileNamePrefix=None, dimensions=None, region=None,
scale=None, crs=None, crsTransform=None, maxPixels=None,
shardSize=None, fileDimensions=None, skipEmptyTiles=None,
fileFormat=None, formatOptions=None, priority=None, **kwargs):
"""
Exports an Earth Engine Image to Google Drive.
Args:
image: The ee.Image to export.
description (str, optional): Task description. Defaults to "myExportImageTask".
folder (str, optional): Drive folder name. Defaults to None.
fileNamePrefix (str, optional): Name prefix for exported file. Defaults to None.
dimensions: Dimensions for export. Defaults to None.
region: Export region. Defaults to None.
scale (float, optional): Export scale. Defaults to None.
crs (str, optional): CRS for export. Defaults to None.
crsTransform: CRS transform. Defaults to None.
maxPixels: Maximum pixels. Defaults to None.
shardSize: Shard size. Defaults to None.
fileDimensions: File dimensions. Defaults to None.
skipEmptyTiles: Skip empty tiles. Defaults to None.
fileFormat: File format. Defaults to None.
formatOptions: Format options. Defaults to None.
priority (int, optional): Task priority. Defaults to None.
**kwargs: Additional keyword arguments.
"""
def ee_export_vector_to_drive(collection, description="myExportTableTask",
folder=None, fileNamePrefix=None, fileFormat=None,
selectors=None, maxVertices=None, **kwargs):
"""
Exports an Earth Engine FeatureCollection to Google Drive.
Args:
collection: The ee.FeatureCollection to export.
description (str, optional): Task description. Defaults to "myExportTableTask".
folder (str, optional): Drive folder name. Defaults to None.
fileNamePrefix (str, optional): Name prefix for exported file. Defaults to None.
fileFormat (str, optional): Export file format. Defaults to None.
selectors: Property selectors. Defaults to None.
maxVertices: Maximum vertices per feature. Defaults to None.
**kwargs: Additional keyword arguments.
"""Specialized tools and utilities for working with Google Earth Engine, including tile layer creation, authentication, and API integration.
def ee_tile_layer(ee_object, vis_params: Dict = {}, name: str = "Layer", shown: bool = True, opacity: float = 1.0) -> ipyleaflet.TileLayer: ...
def ee_initialize(token_name: str = "EARTHENGINE_TOKEN", **kwargs) -> None: ...Extensive collection of utility functions for data format conversion, file operations, and geospatial data processing.
def csv_to_geojson(in_csv: str, out_geojson: str = None, latitude: str = "latitude", longitude: str = "longitude") -> None: ...
def shp_to_geojson(in_shp: str, out_geojson: str = None) -> None: ...
def download_from_url(url: str, out_file_name: str = None, out_dir: str = ".", unzip: bool = True) -> str: ...Advanced visualization tools including charts, plots, legends, and timelapse animations for geospatial data analysis.
def bar_chart(data, x: str, y: str, **kwargs) -> None: ...
def line_chart(data, x: str, y: str, **kwargs) -> None: ...
def create_timeseries(ee_object, region: ee.Geometry, start_date: str, end_date: str) -> None: ...Rich collection of interactive widgets for map controls, data inspection, layer management, and custom toolbars.
class LayerManager:
def __init__(self, map_object) -> None: ...
class Inspector:
def __init__(self, map_object) -> None: ...
class Toolbar:
def __init__(self, map_object) -> None: ...AI-powered features including the Genie assistant widget and machine learning utilities for Earth Engine classifiers.
class Genie:
def __init__(self) -> None: ...
def fc_to_classifier(features: ee.FeatureCollection, classifier: str = "RandomForest") -> ee.Classifier: ...def use_folium():
"""
Whether to use the folium or ipyleaflet plotting backend.
Returns:
bool: True if USE_FOLIUM environment variable is set, False otherwise.
"""
def in_colab_shell():
"""
Tests if the code is being executed within Google Colab.
Returns:
bool: True if running in Google Colab, False otherwise.
"""Environment Variables:
USE_FOLIUM: Set to use folium backend instead of ipyleafletUSE_EEREPR: Control Earth Engine object representation (enabled by default)__version__ = "0.36.2"
__author__ = "Qiusheng Wu"
__email__ = "giswqs@gmail.com"