Skip to main content

AGRS – Agricultural Remote Sensing Library

Project description

AGRS – Agricultural Remote Sensing Library

PyPI DOI

Description

AGRS is a domain-focused Python library that turns Sentinel-2 imagery into agronomy-ready features for various agricultural modeling tasks, such as yield modeling, stress analysis, and NPK recommendation.

Instead of dealing with STAC queries, cloud masks, band math, and geometry clipping in every project, AGRS provides opinionated, agriculture-centric pipelines:

  • Search & fetch Sentinel-2 scenes (via Microsoft Planetary Computer STAC).
  • Compute standard indices (NDVI, EVI, SAVI, NDWI, NDMI, GCI, NDRE, RECI, NBR, NBR2).
  • Select snapshots using agronomic strategies (fractions of season, specific dates, best cloud-free scenes).
  • Aggregate to field-level features per index and growth stage (early/mid/late season) with statistics (mean, median, min, max, std and more).
  • Return a tidy DataFrame ready to join with yield, NPK, and management tables.

The goal is to maximize value for agricultural ML workflows: field trial analysis, site-specific NPK optimization, and crop monitoring.

Key features

  • Sentinel-2 access via Planetary Computer STAC API.
  • Automatic band selection (default: all available bands) or user-defined.
  • Built-in index formulas:
    • NDVI, EVI, SAVI, NDWI, NDMI, GCI, NDRE, RECI, NBR, NBR2
    • Robust handling of missing bands and divide-by-zero (graceful skip + warnings).
  • Snapshot selection strategies:
    • fractional – e.g., snapshots near 30%, 60%, 90% of the season.
    • fixed_date – snapshot closest to a given date.
    • top_n_cloudfree – N lowest-cloud scenes in the period.
  • Field-level aggregation:
    • For each index and stage: mean, median, min, max, std.
    • Early, mid, late stages defined as 0–33%, 33–66%, 66–100% of season duration.

Quick example

import geopandas as gpd
from shapely.geometry import Point
from agrs.client import s2agc

field_geom = Point(-8.0, 32.0)

fields = gpd.GeoDataFrame(
    {
        "field_id": [1],
        "geometry": [field_geom],
    },
    crs="EPSG:4326",
)

client = s2agc(
    source="planetary_computer",
    max_cloud=0.2,
)

features_df = client.get_features(
    fields=fields,
    field_id_col="field_id",
    start_date="2018-10-01",
    end_date="2019-06-30",
    crop="wheat",
    n_snapshots=4,
    snapshot_strategy="fractional",
    fractions=[0.3, 0.6, 0.9, 1.0],
)

print(features_df.head())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agrs-0.1.3.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agrs-0.1.3-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file agrs-0.1.3.tar.gz.

File metadata

  • Download URL: agrs-0.1.3.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for agrs-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ed7342ef71e8f62f583a57aee4916d704d95a392943161cc62a3c1330c0bc0e7
MD5 020dba6bc80262657805569de4c30561
BLAKE2b-256 a40c19fa107a1f38e34a92fb5482ffff94a7a7752f8e44d3006e707debe7e210

See more details on using hashes here.

File details

Details for the file agrs-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: agrs-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for agrs-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 375791292ca4564b4c7de18b8a9b76b086777bf3ee1f5e37037796240265cca2
MD5 ffd0f8cb256a6a90ad0f0f3f5e593248
BLAKE2b-256 026ce9c10834c0c5bd24c2229a8c0e8ded99b61a13098ebbf0630bc5b2842a05

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page