Earth Engine¶
GEEProfiler inspects and samples datasets in Google Earth Engine. It is a fetcher: it queries Earth Engine and returns records. It needs the Earth Engine credentials in Configuration and the gee extra.
Google Earth Engine profiler for inspecting and mapping datasets.
feature_collection property writable ¶
Get the current feature collection.
image_collection property writable ¶
Get the current image collection.
_chunk_geodataframe(gdf, chunk_size) ¶
_init_image_collection(value) ¶
Initialize image collection from string, ImageCollection, or Image.
_initialize_ee(service_account, key_path, project_id, data_store=LocalDataStore()) staticmethod ¶
Initialize Earth Engine API using Pydantic-style config fields.
_is_valid_feature_collection(value) ¶
Validate feature collection.
_is_valid_image_collection(value) ¶
Validate image collection.
_prepare_image(band, start_date=None, end_date=None, temporal_reducer=None) ¶
Prepare an ee.Image from the collection with temporal filtering.
Parameters¶
band : str Band to select start_date : str, optional Start date for temporal filtering end_date : str, optional End date for temporal filtering temporal_reducer : str, optional How to reduce temporally (mean, median, max, etc.)
Returns¶
ee.Image Processed image ready for spatial reduction
_process_chunk(chunk, image, band, reducer, scale, max_pixels, tile_scale) ¶
Process a single chunk by reducing image over features.
Parameters¶
chunk : GeoDataFrame Chunk of features to process image : ee.Image Prepared image to reduce band : str Band name (for output column naming) reducer : str Spatial reducer name scale : float Spatial resolution in meters max_pixels : int Maximum pixels per region tile_scale : int Tile scale factor
Returns¶
GeoDataFrame Processed chunk with reduction results
_reduce_regions_with_chunking(gdf, band, reducer, scale, start_date=None, end_date=None, temporal_reducer=None, chunk_size=1000, max_pixels=int(100000000.0), tile_scale=1) ¶
Core method to reduce image over regions with automatic chunking.
This is the unified processing pipeline used by both map_to_points and map_to_zones.
display_band_names() ¶
Print all available band names.
Examples¶
profiler.display_band_names() Available bands (2): 1. avg_rad 2. cf_cvg
display_collection_info() ¶
Print comprehensive information about the collection.
Examples¶
>>> profiler.display_collection_info()¶
GEE Collection Information¶
Dataset ID: nightlights Collection: NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG Type: ImageCollection Number of images: 154
Bands: Available bands (2): 1. avg_rad 2. cf_cvg
Temporal coverage: Date range: From: 2012-04-01 To: 2024-12-01
Configuration
Default reducer: mean Temporal cadence: monthly
============================================================
display_date_range(date_format='%Y-%m-%d') ¶
display_properties(image_index=0) ¶
get_band_names() ¶
get_date_range(date_format='%Y-%m-%d') ¶
get_properties(image_index=0) ¶
map_to_points(gdf, band=None, reducer=None, buffer_radius_m=None, start_date=None, end_date=None, temporal_reducer=None, chunk_size=None, scale=None) ¶
Map GEE values to point locations with optional circular buffers.
This method extracts values from the Earth Engine image/collection at point locations. If buffer_radius_m is provided, circular buffers are created around points and spatial reduction is applied within each buffer.
Parameters¶
gdf : GeoDataFrame Point locations to enrich (must have Point geometries) band : str, optional Band to extract (uses config default if None) reducer : str, optional Spatial reducer: mean, median, min, max, sum, etc. (uses config default if None) buffer_radius_m : float, optional Buffer radius in meters around each point. If None or 0, point values are extracted directly. start_date : str, optional Start date YYYY-MM-DD for temporal filtering (uses config if None) end_date : str, optional End date YYYY-MM-DD for temporal filtering (uses config if None) temporal_reducer : str, optional How to aggregate over time if multiple images: mean, median, max, etc. (uses config default if None) chunk_size : int, optional Features per chunk for API rate limiting (uses config default if None) scale : float, optional Spatial resolution in meters (uses config/dataset default if None)
Returns¶
GeoDataFrame Enriched GeoDataFrame with new column: {band}_{reducer}
Examples¶
Extract nightlight values at school points with 1km buffers¶
profiler = GEEProfiler(dataset_id="nightlights") enriched = profiler.map_to_points( ... gdf=schools, ... band="avg_rad", ... reducer="mean", ... buffer_radius_m=1000, ... start_date="2020-01-01", ... end_date="2020-12-31" ... ) print(enriched[["school_id", "avg_rad_mean"]].head())
map_to_zones(gdf, band=None, reducer=None, start_date=None, end_date=None, temporal_reducer=None, chunk_size=None, scale=None) ¶
Map GEE values to polygon zones with spatial aggregation.
This method aggregates values from the Earth Engine image/collection within polygon boundaries (e.g., administrative zones, grid cells).
Parameters¶
gdf : GeoDataFrame Polygon zones to aggregate over band : str, optional Band to extract (uses config default if None) reducer : str, optional Spatial reducer: mean, median, min, max, sum, etc. (uses config default if None) start_date : str, optional Start date YYYY-MM-DD for temporal filtering end_date : str, optional End date YYYY-MM-DD for temporal filtering temporal_reducer : str, optional How to aggregate over time: mean, median, max, etc. chunk_size : int, optional Features per chunk for API rate limiting scale : float, optional Spatial resolution in meters
Returns¶
GeoDataFrame Enriched GeoDataFrame with new column: {band}_{reducer}
Examples¶
Aggregate population within admin boundaries¶
profiler = GEEProfiler(dataset_id="population") zones_enriched = profiler.map_to_zones( ... gdf=admin_boundaries, ... band="population_density", ... reducer="sum", ... start_date="2020-01-01", ... end_date="2020-12-31" ... ) print(zones_enriched[["admin_name", "population_density_sum"]].head())