Skip to main content

Python SDK for cropl — crop yield prediction powered by satellite imagery and machine learning

Project description

cropl

Python SDK for cropl — crop yield prediction powered by satellite imagery and machine learning.

Predict crop yields by providing location, crop, and planting information. Built for developers, actuaries, insurers, and government agencies who need programmatic access to yield forecasts.

Preview Release — This is the demo/preview version of the cropl SDK. It uses a local prediction engine with realistic modeled outputs calibrated from a pilot across 847 fields in 28 states. Production API with real satellite data and live model inference is coming soon.

Installation

pip install cropl

For DataFrame support:

pip install cropl[pandas]

Quickstart

import cropl

result = cropl.predict(
    location="Story County, IA",
    crop="corn",
    planting_date="2026-04-15",
)

print(f"Predicted yield: {result.yield_value} {result.yield_unit}")
print(f"Confidence: {result.confidence}%")
print(result.summary())

API Reference

cropl.predict()

Generate a single crop yield prediction.

result = cropl.predict(
    # Required
    location="Story County, IA",  # County+state, zip code, or FIPS code
    crop="corn",                   # corn, soybeans, wheat, cotton, rice
    planting_date="2026-04-15",    # YYYY-MM-DD

    # Optional
    irrigation="rainfed",          # rainfed, center_pivot, drip, flood
    tillage="conventional",        # conventional, no_till, strip_till, reduced
    temp_adjustment=0,             # -10 to +10 (°F offset from historical avg)
    rain_adjustment=0,             # -50 to +50 (% offset from historical avg)
    field_acres=None,              # float — enables revenue estimate
)

Returns: PredictionResult with:

Attribute Type Description
yield_value float Predicted yield (e.g., 191.3)
yield_unit str Unit — bu/acre, lb/acre, or cwt/acre
confidence float Confidence score (0–100)
mape float Model error rate for this crop/region
location str Resolved location name
county str County name
state str State abbreviation
fips str FIPS code
crop str Crop name
planting_date str Input planting date
growth_projection list[dict] Monthly yield progression
ndvi_timeline list[dict] Monthly NDVI values
factors list[dict] Contributing factors with impact scores
revenue_estimate float | None Revenue estimate (if field_acres provided)
price_per_unit float Market price used for revenue calc
timestamp str ISO timestamp of prediction

Convenience methods:

result.to_dict()       # dict representation
result.to_json()       # JSON string
result.to_dataframe()  # pandas DataFrame (single row)
result.summary()       # formatted string for printing

cropl.predict_batch()

Run multiple predictions at once.

results = cropl.predict_batch([
    {"location": "Story County, IA", "crop": "corn", "planting_date": "2026-04-15"},
    {"location": "50011", "crop": "soybeans", "planting_date": "2026-05-20"},
    {"location": "20135", "crop": "wheat", "planting_date": "2026-09-10"},
])
# Returns: list[PredictionResult]

cropl.predict_dataframe()

Run predictions from a pandas DataFrame.

import pandas as pd

df = pd.DataFrame([
    {"location": "Story County, IA", "crop": "corn", "planting_date": "2026-04-15"},
    {"location": "50011", "crop": "soybeans", "planting_date": "2026-05-20"},
])
results_df = cropl.predict_dataframe(df)

# Custom column names
results_df = cropl.predict_dataframe(
    df,
    location_col="county",
    crop_col="crop",
    date_col="plant_date",
)

cropl.list_crops()

List all supported crops with metadata.

crops = cropl.list_crops()
# [
#     {"name": "corn", "yield_unit": "bu/acre", "base_yield": 187.3, "planting_season": "Apr-May"},
#     {"name": "soybeans", "yield_unit": "bu/acre", "base_yield": 51.2, "planting_season": "May-Jun"},
#     ...
# ]

cropl.model_accuracy()

Get model accuracy metrics for a crop and region.

acc = cropl.model_accuracy(crop="corn", region="corn_belt")
# {"mape": 8.1, "rmse": 18.4, "accuracy_pct": 92, "r_squared": 0.87, "sample_size": 312}

cropl.market_price()

Get current market price for a crop.

price = cropl.market_price(crop="corn")
# {"crop": "corn", "price": 4.53, "unit": "$/bu", "source": "USDA", "as_of": "2026-03-01"}

cropl.resolve_location()

Resolve a location string to county, state, FIPS, and region.

loc = cropl.resolve_location("50011")
# {"county": "Story County", "state": "IA", "fips": "19169", "region": "corn_belt"}

Supported Crops

Crop Base Yield Unit Planting Season
Corn ~187 bu/acre Apr–May
Soybeans ~51 bu/acre May–Jun
Wheat ~52 bu/acre Sep–Oct
Cotton ~884 lb/acre Apr–Jun
Rice ~75 cwt/acre Mar–Apr

Location Formats

Three input formats are supported:

Format Example
County + State "Story County, IA" or "Story, Iowa"
Zip Code "50011"
FIPS Code "19169"

All formats resolve internally to county + state + FIPS code.

Revenue Estimation

Pass field_acres to get a revenue estimate based on predicted yield and current market prices:

result = cropl.predict(
    location="Story County, IA",
    crop="corn",
    planting_date="2026-04-15",
    field_acres=160,
)
print(f"Estimated revenue: ${result.revenue_estimate:,.2f}")

Production API

This preview SDK uses a local prediction engine. The production version connects to cropl's API with real satellite imagery, weather data, and trained ML models.

When the production API is available:

import cropl

# Switch to production API — same predict() interface
cropl.configure(api_key="your-api-key")

result = cropl.predict(
    location="Story County, IA",
    crop="corn",
    planting_date="2026-04-15",
)

Visit cropl.co to learn more.

License

Copyright 2026 cropl. All rights reserved.

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

cropl-0.1.1.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

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

cropl-0.1.1-py3-none-any.whl (18.9 kB view details)

Uploaded Python 3

File details

Details for the file cropl-0.1.1.tar.gz.

File metadata

  • Download URL: cropl-0.1.1.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for cropl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fd3e0c5a1cc4dd825d1ff692503d2ae8ca46238362c099296b747411075e773f
MD5 af0b4117ab8577aa2b43704f585669d2
BLAKE2b-256 d70e276367ae60c6f9c7d463469bc4d28314a2903b7a39350cff0c515f5e4f2a

See more details on using hashes here.

File details

Details for the file cropl-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cropl-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for cropl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 36ff4fa5680cb4b935925ee165847d14e6bb358e9b073856e931f3c8244b6ca3
MD5 6dee51526c5e121a043fc3e815b2ab39
BLAKE2b-256 732c33722adf7e4ea4575dff30e6f17b98e6f2d0ecc4eb7175c3c02c9eec0d1e

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