{
 "schema_version": 1,
 "generated": "2026-11-09",
 "id": "torchgeo-torchgeo--sample-landsat-and-cropland-patches-with-torchgeo",
 "repo": "torchgeo/torchgeo",
 "repo_url": "https://github.com/torchgeo/torchgeo",
 "repo_slug": "torchgeo-torchgeo",
 "title": "Build a crop mapping dataset from Landsat and CDL",
 "page_title": "How to build a crop mapping dataset from Landsat and CDL with Torchgeo",
 "summary": "Combine Landsat 7 and 8 with a union, intersect them with the Cropland Data Layer, and sample random patches for training.",
 "who": "A researcher building a crop type segmentation model.",
 "problem": "Aligning large rasters from different sensors and labels by hand is error prone.",
 "outcome": "A PyTorch DataLoader of image and mask patches drawn only where both sources exist.",
 "steps": [
  "Install with `pip install torchgeo`",
  "Create Landsat7 and Landsat8 datasets from your files and join them with the | operator",
  "Load CDL with download=True and checksum=True, and intersect with & so samples need both",
  "Wrap it with RandomPatchSampler(size=256, length=10000) and a DataLoader using stack_samples, then iterate batches of image and mask"
 ],
 "agent_prompt": "With torchgeo/torchgeo, write a script that unions my Landsat 7 and 8 scenes in <data folder>, intersects them with CDL, and prints the shapes of the first batch from a RandomPatchSampler DataLoader.",
 "agents": [
  "claude-code",
  "codex",
  "cursor",
  "gemini-cli"
 ],
 "difficulty": "Advanced",
 "time": "2 hours",
 "basis": "readme",
 "caveat": "The README notes CDL is a single image covering the continental United States, so the download is large.",
 "category": "Data and analytics",
 "tags": [
  "Data and analytics"
 ],
 "lang": "python",
 "requirements": [
  "Python with `pip install torchgeo` (or `uv add torchgeo`)",
  "Enough disk space for the satellite datasets you download",
  "A GPU for training, as with any PyTorch project"
 ],
 "risk": "none",
 "seen_in_the_wild": false,
 "mentioned_publicly": false,
 "risks": [],
 "best": false,
 "score": 0.9,
 "evidence": [],
 "url": "https://dedupedai.com/use-cases/torchgeo-torchgeo/sample-landsat-and-cropland-patches-with-torchgeo/",
 "md": "https://dedupedai.com/use-cases/torchgeo-torchgeo/sample-landsat-and-cropland-patches-with-torchgeo/index.md",
 "disclaimer": "Deduped lists open-source repositories that belong to other people. We do not own, maintain, audit, or vouch for any of them, and a repo appearing here is not an endorsement or a safety check. The use cases, steps, and prompts are written by AI and may be incomplete, outdated, or just wrong. Where a use case is marked \"Seen in the wild\", we link to public posts where someone described something similar, but we have not verified those posts and the use case itself is still our AI's own write-up. Use all of this at your own risk. Only run code, commands, or agents on systems and accounts you are authorized to use, and read the code and every command before you run it, especially anything that touches credentials, files, or the network. Nothing here is professional, security, legal, or financial advice. All trademarks and project names belong to their respective owners, and their use here does not imply affiliation. Content is provided as is, without warranties of any kind. Found a mistake, a safety problem, or something you want removed? Email hello@dedupedai.com and we will look at it promptly.",
 "api": "https://dedupedai.com/api/v1/usecases/torchgeo-torchgeo--sample-landsat-and-cropland-patches-with-torchgeo.json",
 "api_version": "v1"
}
