---
name: aafc-annual-crop-inventory-ingestion
description: "How to get AAFC Annual Crop Inventory data into a pandas DataFrame and Parquet: access, the request, the format, limits, quirks and terms."
---

# Sample AAFC 2025 crop classes into pandas and Parquet

Source entry: https://signal-lab-jet.vercel.app/datasets/aafc-annual-crop-inventory
Provider: https://open.canada.ca/data/en/dataset/ba2645d5-4458-414d-b196-6303ac06c1c9
Checked against the provider's documentation: 2026-11-01

## Access
- No account or key. The ArcGIS ImageServer getSamples endpoint and crop-class CSV are public.

## Request
```bash
curl --get 'https://agriculture.canada.ca/imagery-images/rest/services/annual_crop_inventory/2025/ImageServer/getSamples' --data-urlencode 'geometry={"points":[[-106,52],[-97,50],[-113,53],[-79,44],[-72,46]],"spatialReference":{"wkid":4326}}' --data-urlencode 'geometryType=esriGeometryMultipoint' --data-urlencode 'returnFirstValueOnly=true' --data-urlencode 'f=json'
```

## Format
ArcGIS REST JSON samples with input location, class value, source raster ID and resolution; a separate CSV maps numeric codes to English and French class labels and colours.

## Load into pandas and Parquet
Needs Python 3 with requests, pandas and pyarrow.
```python
"""Sample five coordinates from the AAFC 2025 crop inventory -> pandas -> Parquet."""
import io
import requests
import pandas as pd

SERVICE = "https://agriculture.canada.ca/imagery-images/rest/services/annual_crop_inventory/2025/ImageServer/getSamples"
CLASSES = "https://agriculture.canada.ca/atlas/data_donnees/annualCropInventory/supportdocument_documentdesupport/aci_crop_classifications_iac_classifications_des_cultures.csv"
params = {
    "geometry": '{"points":[[-106,52],[-97,50],[-113,53],[-79,44],[-72,46]],"spatialReference":{"wkid":4326}}',
    "geometryType": "esriGeometryMultipoint",
    "returnFirstValueOnly": "true",
    "f": "json",
}
r = requests.get(SERVICE, params=params, timeout=60)
r.raise_for_status()
samples = pd.json_normalize(r.json()["samples"])
samples["Code"] = pd.to_numeric(samples["value"])
c = requests.get(CLASSES, timeout=60)
c.raise_for_status()
classes = pd.read_csv(io.BytesIO(c.content), encoding="latin-1")[["Code", "Label"]]
df = samples.merge(classes, on="Code", how="left")
df.to_parquet("aafc_crop_inventory_samples.parquet", index=False)
print(len(df), "samples", "; ".join(f'{int(x.Code)}={x.Label}' for x in df.itertuples()))
```
Run by us on 2026-11-01 (python 3.13.5 | pandas 3.1.0 | pyarrow 26.0.0 | requests 2.34.2). Result: 5 samples 34=Urban/developed; 158=Soybeans; 146=Spring wheat; 122=Pasture/forages; 146=Spring wheat

## Limits
- Rate limit: Not stated.
- The example samples five coordinates; use tiled raster downloads or bounded service requests for area analysis.
- The product is annual rather than real time.

## Quirks
- getSamples may return sample rows in an order different from the input points; use locationId to restore input order.
- Join the numeric value to the classification CSV before interpreting a pixel.
- The source classification CSV is bilingual and was decoded as Latin-1 in the checked environment.

## Terms and attribution
- Open Government Licence – Canada permits commercial and non-commercial reuse under its conditions.
- Acknowledge the information source and, where possible, link to the licence.
- Terms page: https://open.canada.ca/en/open-government-licence-canada

## Sources
- https://open.canada.ca/data/en/dataset/ba2645d5-4458-414d-b196-6303ac06c1c9: "Beginning with the 2011 growing season, this activity has been extended to other provinces in support of a national crop inventory."
- https://open.canada.ca/data/en/dataset/ba2645d5-4458-414d-b196-6303ac06c1c9: "To date this approach can consistently deliver a crop inventory that meets the overall target accuracy of at least 85% at a final spatial resolution of 30m (56m in 2009 and 2010)."
- https://open.canada.ca/en/open-government-licence-canada: "The Information Provider grants you a worldwide, royalty-free, perpetual, non-exclusive licence to use the Information, including for commercial purposes"

## Help improve this skill
Missing a source, or see something to improve? Call the MCP tool suggest_source or feedback (or POST /api/suggest or /api/feedback). Reviewed ideas: https://signal-lab-jet.vercel.app/agent-suggestions

Information for educational purposes only. Free tiers, limits and licenses belong to the providers and may change; check the provider's own terms before using the data.
