CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-geemap

A Python package for interactive geospatial analysis and visualization with Google Earth Engine

Pending
Overview
Eval results
Files

interactive-mapping.mddocs/

Interactive Mapping

Core mapping functionality providing interactive visualization capabilities for geospatial data with multiple backend support and comprehensive Earth Engine integration.

Capabilities

Map Class

Main interactive map class that supports multiple backends (ipyleaflet, folium, plotly, kepler.gl, pydeck, maplibre) with automatic backend selection based on environment configuration.

class Map:
    """Interactive map class with Earth Engine integration."""
    
    def __init__(
        self,
        center: List[float] = [20, 0],
        zoom: int = 2,
        height: str = "600px",
        width: str = "100%",
        basemap: str = "OpenStreetMap",
        **kwargs
    ) -> None:
        """
        Initialize interactive map.
        
        Args:
            center: Map center coordinates [latitude, longitude]
            zoom: Initial zoom level
            height: Map height in CSS format
            width: Map width in CSS format  
            basemap: Base map to use
            **kwargs: Additional map parameters
        """

Layer Management

Add and manage map layers including Earth Engine assets, local data, and various tile services.

def addLayer(
    self,
    ee_object,
    vis_params: Dict = {},
    name: str = None,
    shown: bool = True,
    opacity: float = 1.0
) -> None:
    """
    Add layer to map.
    
    Args:
        ee_object: Earth Engine object (Image, ImageCollection, FeatureCollection, Geometry)
        vis_params: Visualization parameters
        name: Layer name for display
        shown: Whether layer is visible
        opacity: Layer opacity (0-1)
    """

def add_tile_layer(
    self,
    url: str,
    name: str = "TileLayer",
    attribution: str = "",
    opacity: float = 1.0,
    shown: bool = True,
    **kwargs
) -> None:
    """
    Add tile layer to map.
    
    Args:
        url: Tile layer URL template
        name: Layer name
        attribution: Attribution text
        opacity: Layer opacity (0-1)
        shown: Whether layer is visible
        **kwargs: Additional tile layer parameters
    """

def add_geojson(
    self,
    data,
    style: Dict = {},
    hover_style: Dict = {},
    style_callback: callable = None,
    fill_colors: List[str] = None,
    info_mode: str = "on_hover",
    **kwargs
) -> None:
    """
    Add GeoJSON data to map.
    
    Args:
        data: GeoJSON data (dict, str path, or URL)
        style: Default style dictionary
        hover_style: Style when hovering
        style_callback: Function for dynamic styling
        fill_colors: List of fill colors for features
        info_mode: How to display feature information
        **kwargs: Additional GeoJSON layer parameters
    """

def add_shp(
    self,
    in_shp: str,
    style: Dict = {},
    hover_style: Dict = {},
    style_callback: callable = None,
    fill_colors: List[str] = None,
    info_mode: str = "on_hover",
    **kwargs 
) -> None:
    """
    Add shapefile to map.
    
    Args:
        in_shp: Path to shapefile
        style: Default style dictionary
        hover_style: Style when hovering
        style_callback: Function for dynamic styling
        fill_colors: List of fill colors for features
        info_mode: How to display feature information
        **kwargs: Additional parameters
    """

Map Navigation and Control

Methods for controlling map view, center, and zoom programmatically.

def centerObject(self, ee_object, zoom: int = None) -> None:
    """
    Center map on Earth Engine object.
    
    Args:
        ee_object: Earth Engine object to center on
        zoom: Zoom level (optional)
    """

def setCenter(self, lon: float, lat: float, zoom: int = None) -> None:
    """
    Set map center coordinates.
    
    Args:
        lon: Longitude
        lat: Latitude  
        zoom: Zoom level (optional)
    """

def setOptions(self, mapTypeId: str = None, styles: Dict = None, types: List[str] = None) -> None:
    """
    Set map options.
    
    Args:
        mapTypeId: Map type identifier
        styles: Map styling options
        types: Available map types
    """

def getCenter(self) -> Dict[str, float]:
    """
    Get current map center.
    
    Returns:
        Dict containing 'lon' and 'lat' keys
    """

def getZoom(self) -> int:
    """
    Get current zoom level.
    
    Returns:
        Current zoom level
    """

def getBounds(self) -> List[List[float]]:
    """
    Get current map bounds.
    
    Returns:
        Bounds as [[south, west], [north, east]]
    """

Drawing and Interaction

Interactive drawing tools and user interaction capabilities.

@property
def draw_control(self) -> Any:
    """Get the draw control widget."""

@property
def draw_features(self) -> List[Any]:
    """Get list of drawn features."""

@property  
def draw_last_feature(self) -> Optional[Any]:
    """Get the last drawn feature."""

@property
def user_roi(self) -> Optional[Any]:
    """Get user region of interest from drawing."""

def add_draw_control(self, **kwargs) -> None:
    """Add drawing control to map."""

def remove_draw_control(self) -> None:
    """Remove drawing control from map."""

Basemap Management

Access and manage various basemap providers and tile services.

def add_basemap(self, basemap: str = "OpenStreetMap") -> None:
    """
    Add basemap to map.
    
    Args:
        basemap: Basemap name from available basemaps
    """

def get_basemap(name: str) -> Dict:
    """
    Get basemap configuration.
    
    Args:
        name: Basemap identifier
        
    Returns:
        Basemap configuration dictionary
    """

Map Linking

Create linked maps for comparison and synchronized viewing.

def linked_maps(
    rows: int = 2,
    cols: int = 2,
    height: str = "400px",
    center: List[float] = [20, 0],
    zoom: int = 2
) -> widgets.GridBox:
    """
    Create linked maps for comparison.
    
    Args:
        rows: Number of rows
        cols: Number of columns
        height: Map height
        center: Initial center coordinates
        zoom: Initial zoom level
        
    Returns:
        Grid widget containing linked maps
    """

Usage Examples

Basic Map Creation

import geemap

# Create basic map
m = geemap.Map(center=[40, -100], zoom=4)

# Add Earth Engine layer
import ee
ee.Initialize()

image = ee.Image('USGS/SRTMGL1_003')
vis_params = {'min': 0, 'max': 4000, 'palette': ['blue', 'green', 'red']}
m.addLayer(image, vis_params, 'Elevation')

# Display map
m

Adding Local Data

# Add GeoJSON
m.add_geojson('path/to/data.geojson', style={'color': 'red', 'weight': 2})

# Add shapefile  
m.add_shp('path/to/data.shp', style={'fillColor': 'blue', 'weight': 1})

Map Navigation

# Center on specific location
m.setCenter(-122.4, 37.8, zoom=10)  # San Francisco

# Center on Earth Engine object
roi = ee.Geometry.Point([-122.4, 37.8])
m.centerObject(roi, zoom=12)

Types

# Visualization parameters for Earth Engine layers
VisParams = Dict[str, Union[int, float, List[str], List[int], List[float]]]

# Style parameters for vector layers  
Style = Dict[str, Union[str, int, float, bool]]

# Map bounds format
Bounds = List[List[float]]  # [[south, west], [north, east]]

# Map center format
Center = Dict[str, float]  # {'lon': longitude, 'lat': latitude}

Install with Tessl CLI

npx tessl i tessl/pypi-geemap

docs

ai-ml.md

data-conversion.md

data-export.md

earth-engine.md

index.md

interactive-mapping.md

visualization.md

widgets-tools.md

tile.json