DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to build a crop mapping dataset from Landsat and CDL with Torchgeo

Combine Landsat 7 and 8 with a union, intersect them with the Cropland Data Layer, and sample random patches for training.

Short answer: Install with pip install torchgeo; then 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. All steps.

Who it is forA researcher building a crop type segmentation model.

The problemAligning large rasters from different sensors and labels by hand is error prone.

The outcomeA PyTorch DataLoader of image and mask patches drawn only where both sources exist.

What you need first

  • 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

Steps

  1. Install with pip install torchgeo
  2. Create Landsat7 and Landsat8 datasets from your files and join them with the | operator
  3. Load CDL with download=True and checksum=True, and intersect with & so samples need both
  4. Wrap it with RandomPatchSampler(size=256, length=10000) and a DataLoader using stack_samples, then iterate batches of image and mask

Prompt for your agent

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.

Caveat. The README notes CDL is a single image covering the continental United States, so the download is large.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for torchgeo/torchgeo and "Build a crop mapping dataset from Landsat and CDL"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer