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.2.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.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agrs-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 ac3c8ba3bdb9e4a7e21965c11f7cf97f81deb074f857d37350190179df6ca6c8
MD5 0852eacf3338d2d2a4f1b5de41d32dce
BLAKE2b-256 2f84c5ddf0db2f4524b5761da260b19456d621753be95923bcf8d14fbee00d2f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agrs-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dcdff1198f9e4358b965834b9f73d2c5bb7871aee79c2bc6eb05dfef91a5e3a5
MD5 63248fc656ab86f69101d81870dae92e
BLAKE2b-256 0e10d81a412a651a623e27fc45269e75c2eeb1cd7ce806b98ae78af901299cbf

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