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

data-export.mddocs/

Data Export and Processing

Comprehensive data export capabilities for Earth Engine assets to various formats and storage destinations including Google Drive, Cloud Storage, and local files. Provides extensive functionality for processing Earth Engine computations and exporting results.

Capabilities

Image Export

Export Earth Engine images to various destinations with customizable parameters for resolution, region, and format.

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): A default scale to use for any bands that do not specify one
        crs (str, optional): A default CRS string to use for any bands that do not explicitly specify one
        crs_transform (list, optional): A default affine transform to use for any bands that do not specify one
        region: A polygon specifying a region to download
        dimensions (list, optional): An optional array of two integers defining the width and height to which the band is cropped
        file_per_band (bool, optional): Whether to produce a different GeoTIFF per band. Defaults to False
        format (str, optional): One of "ZIPPED_GEO_TIFF" (default), "GEO_TIFF", "NPY"
        unzip (bool, optional): Whether to unzip the downloaded file. Defaults to True
        unmask_value (float, optional): The value to use for pixels that are masked in the input image
        timeout (int, optional): The timeout in seconds for the request. Defaults to 300
        proxies (dict, optional): A dictionary of proxy servers to use. Defaults to None
        verbose (bool, optional): Whether to print out descriptive text. Defaults to True
    """

def ee_export_image_to_drive(
    image,
    description="myExportImageTask",
    folder: str = None,
    fileNamePrefix: str = None,
    dimensions: str = None,
    region: ee.Geometry = None,
    scale: float = None,
    crs: str = None,
    crsTransform: List[float] = None,
    maxPixels: int = 1e13,
    shardSize: int = None,
    fileDimensions: List[int] = None,
    skipEmptyTiles: bool = None,
    fileFormat: str = None,
    formatOptions: Dict = None,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine image to Google Drive.
    
    Args:
        ee_object: Earth Engine Image to export
        description: Task description
        folder: Drive folder name
        fileNamePrefix: Output file name prefix
        dimensions: Output dimensions
        region: Export region
        scale: Export resolution in meters
        crs: Coordinate reference system
        crsTransform: Coordinate transform matrix
        maxPixels: Maximum pixels to export
        shardSize: Shard size for large exports
        fileDimensions: File dimensions for tiled exports
        skipEmptyTiles: Skip empty tiles
        fileFormat: Output format (GeoTIFF, TFRecord)
        formatOptions: Format-specific options
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_image_to_asset(
    ee_object,
    description: str,
    assetId: str,
    pyramidingPolicy: Dict = None,
    dimensions: str = None,
    region: ee.Geometry = None,
    scale: float = None,
    crs: str = None,
    crsTransform: List[float] = None,
    maxPixels: int = 1e13,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine image to Earth Engine asset.
    
    Args:
        ee_object: Earth Engine Image to export
        description: Task description
        assetId: Asset ID for output
        pyramidingPolicy: Pyramiding policy for bands
        dimensions: Output dimensions
        region: Export region
        scale: Export resolution in meters
        crs: Coordinate reference system
        crsTransform: Coordinate transform matrix
        maxPixels: Maximum pixels to export
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_image_to_cloud_storage(
    ee_object,
    description: str,
    bucket: str,
    fileNamePrefix: str = None,
    dimensions: str = None,
    region: ee.Geometry = None,
    scale: float = None,
    crs: str = None,
    crsTransform: List[float] = None,
    maxPixels: int = 1e13,
    shardSize: int = None,
    fileDimensions: List[int] = None,
    skipEmptyTiles: bool = None,
    fileFormat: str = None,
    formatOptions: Dict = None,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine image to Google Cloud Storage.
    
    Args:
        ee_object: Earth Engine Image to export
        description: Task description
        bucket: GCS bucket name
        fileNamePrefix: Output file name prefix
        dimensions: Output dimensions
        region: Export region
        scale: Export resolution in meters
        crs: Coordinate reference system
        crsTransform: Coordinate transform matrix
        maxPixels: Maximum pixels to export
        shardSize: Shard size for large exports
        fileDimensions: File dimensions for tiled exports
        skipEmptyTiles: Skip empty tiles
        fileFormat: Output format
        formatOptions: Format-specific options
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

Image Collection Export

Export Earth Engine image collections with options for batch processing and various output formats.

def ee_export_image_collection(
    ee_object: ee.ImageCollection,
    out_dir: str,
    scale: float = None,
    region: ee.Geometry = None,
    file_per_band: bool = False,
    **kwargs
) -> None:
    """
    Export Earth Engine image collection to local directory.
    
    Args:
        ee_object: Earth Engine ImageCollection to export
        out_dir: Output directory
        scale: Export resolution in meters
        region: Export region geometry
        file_per_band: Export each band as separate file
        **kwargs: Additional export parameters
    """

def ee_export_image_collection_to_drive(
    ee_object: ee.ImageCollection,
    folder: str,
    scale: float = None,
    region: ee.Geometry = None,
    fileFormat: str = "GeoTIFF",
    **kwargs
) -> List[ee.batch.Task]:
    """
    Export Earth Engine image collection to Google Drive.
    
    Args:
        ee_object: Earth Engine ImageCollection to export
        folder: Drive folder name
        scale: Export resolution in meters
        region: Export region
        fileFormat: Output format
        **kwargs: Additional parameters
        
    Returns:
        List of export task objects
    """

def ee_export_image_collection_to_asset(
    ee_object: ee.ImageCollection,
    assetFolder: str,
    scale: float = None,
    region: ee.Geometry = None,
    **kwargs
) -> List[ee.batch.Task]:
    """
    Export Earth Engine image collection to Earth Engine assets.
    
    Args:
        ee_object: Earth Engine ImageCollection to export
        assetFolder: Asset folder path
        scale: Export resolution in meters
        region: Export region
        **kwargs: Additional parameters
        
    Returns:
        List of export task objects
    """

def ee_export_image_collection_to_cloud_storage(
    ee_object: ee.ImageCollection,
    bucket: str,
    scale: float = None,
    region: ee.Geometry = None,
    fileFormat: str = "GeoTIFF",
    **kwargs
) -> List[ee.batch.Task]:
    """
    Export Earth Engine image collection to Google Cloud Storage.
    
    Args:
        ee_object: Earth Engine ImageCollection to export
        bucket: GCS bucket name
        scale: Export resolution in meters
        region: Export region
        fileFormat: Output format
        **kwargs: Additional parameters
        
    Returns:
        List of export task objects
    """

Vector Data Export

Export Earth Engine feature collections and vector data to various formats and destinations.

def ee_export_vector(
    ee_object: ee.FeatureCollection,
    filename: str,
    **kwargs
) -> None:
    """
    Export Earth Engine feature collection to local file.
    
    Args:
        ee_object: Earth Engine FeatureCollection to export
        filename: Output filename
        **kwargs: Additional export parameters
    """

def ee_export_vector_to_drive(
    collection: ee.FeatureCollection,
    description: str,
    folder: str = None,
    fileNamePrefix: str = None,
    fileFormat: str = None,
    selectors: List[str] = None,
    maxVertices: int = None,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine feature collection to Google Drive.
    
    Args:
        collection: Earth Engine FeatureCollection to export
        description: Task description
        folder: Drive folder name
        fileNamePrefix: Output file name prefix
        fileFormat: Output format (SHP, GeoJSON, KML, KMZ, CSV)
        selectors: Property names to include
        maxVertices: Maximum vertices per feature
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_vector_to_asset(
    collection: ee.FeatureCollection,
    description: str,
    assetId: str,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine feature collection to Earth Engine asset.
    
    Args:
        collection: Earth Engine FeatureCollection to export
        description: Task description
        assetId: Asset ID for output
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_vector_to_cloud_storage(
    collection: ee.FeatureCollection,
    description: str,
    bucket: str,
    fileNamePrefix: str = None,
    fileFormat: str = None,
    selectors: List[str] = None,
    maxVertices: int = None,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine feature collection to Google Cloud Storage.
    
    Args:
        collection: Earth Engine FeatureCollection to export
        description: Task description
        bucket: GCS bucket name
        fileNamePrefix: Output file name prefix
        fileFormat: Output format
        selectors: Property names to include
        maxVertices: Maximum vertices per feature
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_geojson(
    ee_object,
    filename: str = None,
    **kwargs
) -> Union[Dict, None]:
    """
    Export Earth Engine object as GeoJSON.
    
    Args:
        ee_object: Earth Engine object to export
        filename: Output filename (optional)
        **kwargs: Additional parameters
        
    Returns:
        GeoJSON dictionary if no filename specified
    """

Video Export

Export Earth Engine image collections as video animations.

def ee_export_video_to_drive(
    collection: ee.ImageCollection,
    description: str,
    folder: str = None,
    fileNamePrefix: str = None,
    framesPerSecond: int = 1,
    dimensions: int = None,
    region: ee.Geometry = None,
    scale: float = None,
    crs: str = None,
    crsTransform: List[float] = None,
    maxPixels: int = 1e13,
    maxFrames: int = 1000,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine image collection as video to Google Drive.
    
    Args:
        collection: Earth Engine ImageCollection to export
        description: Task description
        folder: Drive folder name
        fileNamePrefix: Output file name prefix
        framesPerSecond: Video frame rate
        dimensions: Video dimensions
        region: Export region
        scale: Export resolution in meters
        crs: Coordinate reference system
        crsTransform: Coordinate transform matrix
        maxPixels: Maximum pixels per frame
        maxFrames: Maximum number of frames
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

def ee_export_video_to_cloud_storage(
    collection: ee.ImageCollection,
    description: str,
    bucket: str,
    fileNamePrefix: str = None,
    framesPerSecond: int = 1,
    dimensions: int = None,
    region: ee.Geometry = None,
    scale: float = None,
    crs: str = None,
    crsTransform: List[float] = None,
    maxPixels: int = 1e13,
    maxFrames: int = 1000,
    **kwargs
) -> ee.batch.Task:
    """
    Export Earth Engine image collection as video to Google Cloud Storage.
    
    Args:
        collection: Earth Engine ImageCollection to export
        description: Task description
        bucket: GCS bucket name
        fileNamePrefix: Output file name prefix
        framesPerSecond: Video frame rate
        dimensions: Video dimensions
        region: Export region
        scale: Export resolution in meters
        crs: Coordinate reference system
        crsTransform: Coordinate transform matrix
        maxPixels: Maximum pixels per frame
        maxFrames: Maximum number of frames
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

Task Management

Monitor and manage Earth Engine export tasks.

def ee_export_map_to_cloud_storage(
    ee_object,
    description: str,
    bucket: str,
    **kwargs
) -> ee.batch.Task:
    """
    Export map tiles to Google Cloud Storage.
    
    Args:
        ee_object: Earth Engine object to export
        description: Task description
        bucket: GCS bucket name
        **kwargs: Additional parameters
        
    Returns:
        Export task object
    """

Usage Examples

Basic Image Export

import geemap
import ee

# Initialize Earth Engine
ee.Initialize()

# Get an image
image = ee.Image('USGS/SRTMGL1_003')

# Export to Google Drive
task = geemap.ee_export_image_to_drive(
    image,
    description='SRTM_Export',
    folder='Earth_Engine_Exports',
    region=ee.Geometry.Rectangle([-120, 35, -119, 36]),
    scale=30,
    fileFormat='GeoTIFF'
)

# Start the task
task.start()

# Monitor task status
print(task.status())

Image Collection Export

# Get image collection
collection = (ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
              .filterDate('2020-01-01', '2020-12-31')
              .filterBounds(ee.Geometry.Point([-122, 37]))
              .limit(10))

# Export collection to Drive
tasks = geemap.ee_export_image_collection_to_drive(
    collection,
    folder='Landsat_Collection',
    scale=30,
    region=ee.Geometry.Rectangle([-122.5, 36.5, -121.5, 37.5])
)

# Start all tasks
for task in tasks:
    task.start()

Vector Data Export

# Get feature collection
countries = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017')
usa = countries.filter(ee.Filter.eq('country_na', 'United States'))

# Export to Google Drive
task = geemap.ee_export_vector_to_drive(
    usa,
    description='USA_Boundaries',
    folder='Earth_Engine_Exports',
    fileFormat='SHP'
)

task.start()

Types

# Export task type
ExportTask = ee.batch.Task

# Export parameters
ExportParams = Dict[str, Union[str, int, float, bool, List, Dict]]

# File format options
FileFormat = Literal['GeoTIFF', 'TFRecord', 'SHP', 'GeoJSON', 'KML', 'KMZ', 'CSV']

# Task status
TaskStatus = Dict[str, Union[str, int, float]]

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