Skip to main content

AGRS: Agricultural Remote Sensing Library

Project description

AGRS – Agricultural Remote Sensing Library

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.0.tar.gz (10.3 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.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agrs-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 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.0.tar.gz
Algorithm Hash digest
SHA256 3e69d3dc4a5ce7b087d29c063c58a44fa355c7effb5f3c63628057cd13750eab
MD5 43ebc822e8d833c9a36cb6c10153d291
BLAKE2b-256 8ac2424335ebeab4be508250615af01a8d0db89e1a1d91a2824c01dae6de6e84

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agrs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e9160d23ced3fb3c0f142fb8e4123fe8bcb7f2d18fd6e748db538885ecd0e87
MD5 fbc74454f2d2b2a01508ae22bbd46b17
BLAKE2b-256 3f8966d4528a92a34f0ef59a488e30d005796c62552b940263c52ea9dec27abd

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