Skip to main content

Welcome to geeagri

Open in Colab Open in Binder Open In Studio Lab PyPI Version Downloads Documentation Status License

A Python package for agricultural monitoring and analysis using Google Earth Engine


Introduction

geeagri is a Python package that integrates the power of Google Earth Engine (GEE) with domain-specific agricultural analysis. It enables scalable processing, downloading, and visualization of satellite data for crop monitoring, yield estimation, and agro-environmental assessment.

This package builds upon geospatial tools like geemap and simplifies workflows for scientists, researchers, and policymakers working in agriculture. Whether you're interested in vegetation monitoring, drought assessment, phenology extraction, or productivity mapping, geeagri offers tools and prebuilt pipelines to make your analysis easier and faster.

geeagri is ideal for:

  • Researchers working with satellite-derived agricultural indicators.
  • Practitioners and analysts from development, environmental, and governmental organizations.
  • Students and educators looking to learn remote sensing for agriculture.

For a complete list of examples and use cases, visit the notebooks section.


Key Features

  • Long-term Time Series Extraction — Retrieve satellite or climate time series from Google Earth Engine (GEE) for both point and polygon geometries.
  • Image Patch Generation — Extract image tiles or patches from satellite imagery in GEE to support local-scale computer vision or deep learning model training.
  • Multivariate Dimensionality Reduction — Transform complex multivariate datasets into a few principal components while preserving essential information using PCA.
  • Harmonic Regression Analysis — Easily perform harmonic regression on vegetation or climate indices to study seasonal and periodic trends.
  • Cloud-free Time Series Creation — Generate regular, gap-filled, and cloud-free time series from irregular satellite observations.
  • Phenology and Smoothing Tools — Apply smoothing algorithms and extract phenological metrics (Start of Season, Peak of Season, End of Season) from high-resolution satellite data.

Installation

conda create -n geeagri python=3.10
conda activate geeagri
pip install geeagri
# (Optional) Upgrade to the latest version if already installed
pip install --upgrade geeagri

Example Usage

Example 1: Extract timeseries to point

import ee
import geeagri
from geeagri.extract import extract_timeseries_to_point

# Authenticate and initialize the Earth Engine API
ee.Authenticate()
ee.Initialize()

# Define point location (longitude, latitude)
lon, lat = -98.15, 30.50
point = ee.Geometry.Point([lon, lat])

# Load ERA5-Land daily aggregated climate dataset
era5_land = ee.ImageCollection("ECMWF/ERA5_LAND/DAILY_AGGR")

# Extract daily temperature, precipitation, and solar radiation time series
era5_land_point_ts = extract_timeseries_to_point(
    lat=lat,
    lon=lon,
    image_collection=era5_land,
    start_date="2020-01-01",
    end_date="2021-01-01",
    band_names=[
        "temperature_2m_min",
        "temperature_2m_max",
        "total_precipitation_sum",
        "surface_solar_radiation_downwards_sum",
    ],
    scale=11132,  # spatial resolution in meters (~11 km)
)

This example demonstrates how to use geeagri to extract daily climate variable time series (temperature, precipitation, and solar radiation) from the ERA5-Land dataset at a specific geographic point using the Google Earth Engine (GEE) Python API.

Output Plot: ERA5-Land Temperature Time Series

Example 2: Create regular satellite timeseries

import ee
from geeagri.preprocessing import Sentinel2CloudMask, RegularTimeseries

# Authenticate and initialize the Earth Engine API
ee.Authenticate()
ee.Initialize()

# Define the bounding box
bbox = [-98.451233, 38.430732, -98.274765, 38.523996]
region = ee.Geometry.BBox(*bbox)

# Get cloud masked Sentinel-2 image collection
s2_cloud_masker = Sentinel2CloudMask(
    region=region,
    start_date="2020-01-01",
    end_date="2021-01-01",
    cloud_filter=60,
    cloud_prob_threshold=50,
    nir_dark_threshold=0.15,
    shadow_proj_dist=1,
    buffer=50
)

s2_cloud_masked = s2_cloud_masker.get_cloudfree_collection()

# Calculate NDVI
def calculateNDVI(image):
    ndvi = image.expression(
        "(NIR - Red) / (NIR + Red)",
        {"NIR": image.select("B8"), "Red": image.select("B4")},
    ).copyProperties(image, ["system:time_start"])

    ndvi = ee.Image(ndvi).rename("ndvi").clip(region)

    return ndvi


ndvi_col = s2_cloud_masked.map(calculateNDVI)

# Instantiate a 'RegularTimeseries' object
reg_timeseries = RegularTimeseries(
    image_collection=ndvi_col,
    interval=5,  # Interval (in days) between consecutive target dates
    window=45,  # Temporal window in days
)

# Get the regular timeseries
ndvi_regular = reg_timeseries.get_regular_timeseries()

This example demonstrates how to extract a regular, gap-filled NDVI time series from Sentinel-2 imagery using geeagri. First, a Sentinel2CloudMask object is created to mask clouds and shadows over a defined bounding box using thresholds for cloud probability, dark NIR pixels, and shadow projection. The cloud-masked images are then processed with a custom function to calculate NDVI for each image. Finally, a RegularTimeseries object generates a temporally consistent NDVI time series at a specified interval and temporal window. This workflow allows users to efficiently obtain high-quality, regular NDVI time series from raw Sentinel-2 imagery while handling cloud and shadow contamination.

Raw NDVI Time Series with Cloud Gaps: Raw Satellite Time Series with Cloud Gaps

Regular Gap-filled NDVI Time Series: Regular Gap-filled NDVI Time Series


Metadata

Release files for geeagri 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for geeagri 1.0.1
File Size Uploaded Provenance Actions
geeagri-1.0.1.tar.gz 21.2 MB Without provenance Details for geeagri-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for geeagri 1.0.1
File Interpreter ABI Platform Actions
geeagri-1.0.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for geeagri-1.0.1-py2.py3-none-any.whl

Total release size: 21.3 MB

Release files / geeagri-1.0.1.tar.gz

Download URL geeagri-1.0.1.tar.gz
Size 21.2 MB
Tags Source
SHA-256 checksum
How to use checksums
9efa90c79d63cb8552f4c08cd37fc5b1b86de2dc7beace29304ef641e233747c
BLAKE2b-256 checksum
How to use checksums
ebda850b23db49db5be7bba6f2e67a0c55df34b5ac4a3b3920807db5d1eae58d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Release files / geeagri-1.0.1-py2.py3-none-any.whl

Download URL geeagri-1.0.1-py2.py3-none-any.whl
Size 26.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
47f8e563b12200da81f535e4e85a7405335d94908873c784e321dc660f170397
BLAKE2b-256 checksum
How to use checksums
8a2fc66fbd4080ce293a27bf4ffd4f5b9b1e32cadbdbcfc79da7fa55c9a75625
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.0

Security for geeagri 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page