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

earth-engine.mddocs/

Earth Engine Integration

Specialized tools and utilities for working with Google Earth Engine, including tile layer creation, authentication, initialization, and comprehensive API integration features.

Capabilities

Earth Engine Initialization

Initialize and authenticate with Google Earth Engine service with various authentication methods and configuration options.

def ee_initialize(
    token_name: str = "EARTHENGINE_TOKEN",
    auth_args: Dict = None,
    **kwargs
) -> None:
    """
    Initialize Earth Engine with authentication.
    
    Args:
        token_name: Environment variable name for token
        auth_args: Authentication arguments
        **kwargs: Additional initialization parameters
    """

def set_proxy(
    port: int = 1080,
    host: str = "127.0.0.1",
    **kwargs
) -> None:
    """
    Set proxy configuration for Earth Engine.
    
    Args:
        port: Proxy port number
        host: Proxy host address
        **kwargs: Additional proxy parameters
    """

Tile Layer Creation

Create tile layers from Earth Engine objects for visualization in interactive maps.

def ee_tile_layer(
    ee_object,
    vis_params: Dict = {},
    name: str = "Layer",
    shown: bool = True,
    opacity: float = 1.0
) -> ipyleaflet.TileLayer:
    """
    Create Earth Engine tile layer for ipyleaflet maps.
    
    Args:
        ee_object: Earth Engine object (Image, ImageCollection, FeatureCollection)
        vis_params: Visualization parameters
        name: Layer name
        shown: Whether layer is visible
        opacity: Layer opacity (0-1)
        
    Returns:
        ipyleaflet TileLayer object
    """

Visualization Parameters:

  • min, max: Value range for stretching
  • bands: Band selection for RGB visualization
  • palette: Color palette for single-band images
  • gamma: Gamma correction value

Earth Engine Tile Layer Classes

Specialized tile layer classes for different mapping backends.

class EELeafletTileLayer:
    """Earth Engine tile layer for ipyleaflet backend."""
    
    def __init__(
        self,
        ee_object,
        vis_params: Dict = {},
        name: str = "Layer",
        opacity: float = 1.0,
        visible: bool = True,
        **kwargs
    ) -> None:
        """
        Initialize Earth Engine tile layer for ipyleaflet.
        
        Args:
            ee_object: Earth Engine object
            vis_params: Visualization parameters
            name: Layer name
            opacity: Layer opacity
            visible: Layer visibility
            **kwargs: Additional parameters
        """

class EEFoliumTileLayer:
    """Earth Engine tile layer for folium backend."""
    
    def __init__(
        self,
        ee_object,
        vis_params: Dict = {},
        name: str = "Layer",
        opacity: float = 1.0,
        visible: bool = True,
        **kwargs
    ) -> None:
        """
        Initialize Earth Engine tile layer for folium.
        
        Args:
            ee_object: Earth Engine object
            vis_params: Visualization parameters
            name: Layer name
            opacity: Layer opacity
            visible: Layer visibility
            **kwargs: Additional parameters
        """

Authentication and Credentials

Manage Earth Engine authentication and credential handling across different environments.

def is_drive_mounted() -> bool:
    """
    Check if Google Drive is mounted in Colab.
    
    Returns:
        True if Drive is mounted
    """

def credentials_in_drive() -> bool:
    """
    Check for Earth Engine credentials in Google Drive.
    
    Returns:
        True if credentials found in Drive
    """

def credentials_in_colab() -> bool:
    """
    Check for Earth Engine credentials in Colab.
    
    Returns:
        True if credentials found in Colab
    """

def copy_credentials_to_drive() -> None:
    """Copy Earth Engine credentials to Google Drive."""

def copy_credentials_to_colab() -> None:
    """Copy Earth Engine credentials from Drive to Colab."""

Object Information and Utilities

Utilities for inspecting and working with Earth Engine objects.

def get_info(ee_object, **kwargs) -> Dict:
    """
    Get information about Earth Engine object.
    
    Args:
        ee_object: Earth Engine object
        **kwargs: Additional parameters
        
    Returns:
        Information dictionary
    """

def geometry_type(ee_object) -> str:
    """
    Get geometry type of Earth Engine object.
    
    Args:
        ee_object: Earth Engine geometry object
        
    Returns:
        Geometry type string
    """

def build_computed_object_tree(ee_object) -> Dict:
    """
    Build computed object tree for visualization.
    
    Args:
        ee_object: Earth Engine object
        
    Returns:
        Tree structure dictionary
    """

Environment Detection

Detect execution environment for proper Earth Engine integration.

def in_colab_shell() -> bool:
    """
    Test if code is being executed within Google Colab.
    
    Returns:
        True if running in Google Colab
    """

def get_env_var(name: str, default: str = None) -> str:
    """
    Get environment variable value.
    
    Args:
        name: Environment variable name
        default: Default value if not found
        
    Returns:
        Environment variable value
    """

Time Series Inspector

Interactive time series analysis tools for Earth Engine image collections.

def ts_inspector(
    map_object=None,
    left_ts: ee.ImageCollection = None,
    right_ts: ee.ImageCollection = None,
    left_names: List[str] = None,
    right_names: List[str] = None,
    **kwargs
) -> widgets.VBox:
    """
    Create time series inspector widget.
    
    Args:
        map_object: Map object to attach inspector
        left_ts: Left panel time series collection
        right_ts: Right panel time series collection
        left_names: Names for left panel bands
        right_names: Names for right panel bands
        **kwargs: Additional parameters
        
    Returns:
        Time series inspector widget
    """

Data Catalog Integration

Tools for working with Earth Engine data catalog and asset discovery.

class Catalog:
    """Earth Engine data catalog interface."""
    
    def __init__(self) -> None:
        """Initialize catalog interface."""
    
    def search(self, keywords: str = None, **kwargs) -> List[Dict]:
        """
        Search Earth Engine data catalog.
        
        Args:
            keywords: Search keywords
            **kwargs: Additional search parameters
            
        Returns:
            List of matching dataset information
        """

def get_metadata(asset_id: str) -> Dict:
    """
    Get metadata for Earth Engine asset.
    
    Args:
        asset_id: Earth Engine asset ID
        
    Returns:
        Asset metadata dictionary
    """

Usage Examples

Basic Earth Engine Setup

import geemap
import ee

# Initialize Earth Engine
geemap.ee_initialize()

# Alternative initialization with token
geemap.ee_initialize(token_name='MY_EE_TOKEN')

Creating Tile Layers

# Create image tile layer
image = ee.Image('USGS/SRTMGL1_003')
vis_params = {
    'min': 0,
    'max': 4000,
    'palette': ['blue', 'green', 'red']
}

tile_layer = geemap.ee_tile_layer(image, vis_params, 'Elevation')

# Add to map
m = geemap.Map()
m.add_layer(tile_layer)

Authentication in Different Environments

# Check environment and handle credentials
if geemap.in_colab_shell():
    if not geemap.credentials_in_colab():
        if geemap.credentials_in_drive():
            geemap.copy_credentials_to_colab()
        else:
            ee.Authenticate()
            geemap.ee_initialize()
    else:
        geemap.ee_initialize()
else:
    # Local Jupyter environment
    geemap.ee_initialize()

Time Series Analysis

# Create time series inspector
collection = (ee.ImageCollection('MODIS/006/MOD13A2')
              .filterDate('2020-01-01', '2020-12-31')
              .select('NDVI'))

inspector = geemap.ts_inspector(
    left_ts=collection,
    left_names=['NDVI']
)

# Display inspector widget  
inspector

Object Information

# Get Earth Engine object information
image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_044034_20140318')
info = geemap.get_info(image)
print(f"Bands: {info['bands']}")
print(f"Properties: {info['properties']}")

# Check geometry type
geometry = ee.Geometry.Point([-122, 37])
geom_type = geemap.geometry_type(geometry)
print(f"Geometry type: {geom_type}")

Types

# Visualization parameters type
VisParams = Dict[str, Union[int, float, List[str], List[int], List[float]]]

# Earth Engine object info type
ObjectInfo = Dict[str, Any]

# Authentication arguments type
AuthArgs = Dict[str, Union[str, bool, Dict]]

# Asset metadata type
AssetMetadata = Dict[str, Union[str, int, float, List, Dict]]

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