Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Preparing the Fields of the World (FTW) dataset for instance segmentation

1. Motivation

You now understand what Mask R-CNN predicts and how. This page covers the data it will train on: a benchmark dataset built specifically for field-boundary instance segmentation, and what you need to check and prepare before training begins on the next page.

Instance-level labels are expensive to produce, which is exactly why a well-curated benchmark dataset is valuable. Using one lets you focus on the modeling workflow itself in this lesson, while still working with realistic, high-quality data, the same reasoning that motivated using NWPU-VHR-10 in L06 and the Chesapeake land-cover data in L07.


2. Core idea

The Fields of the World (FTW) dataset pairs Sentinel-2 imagery with instance segmentation masks for agricultural field boundaries, across 24 countries. Each chip already comes with a unique integer ID per field baked into its label, exactly the instance-identifier structure from the previous page, so no manual instance derivation is needed. This lesson uses the Luxembourg subset, one of the smallest country subsets, which keeps download and training time manageable while still using real, high-quality annotations.


3. Workflow

The Fields of The World (FTW) dataset contains over 70,000 agricultural image chips across multiple countries. For this workflow, we focus on the Luxembourg subset—a compact dataset ideal for learning instance segmentation pipelines without massive download overhead. Each chip uses 4-band Sentinel-2 imagery (Red, Green, Blue, Near-Infrared) at 10-meter spatial resolution. A 256×256256 \times 256 pixel tile covers a physical area of approximately 2.56 km×2.56 km2.56\text{ km} \times 2.56\text{ km}, paired with instance labels marking individual agricultural field boundaries.


A. Download the Luxembourg subset

The download_ftw() function retrieves the Luxembourg subset and extracts it into the ftw_data/ directory.


B. Explore metadata and spatial splits

The dataset includes a GeoParquet file recording every chip’s location, geometric footprint, and official dataset split (train, val, test).

Visualizing data splits on an interactive map is a critical step in geospatial machine learning. A sound benchmark spreads splits evenly across different geographic landscapes. If test chips cluster in a single region, evaluation results will be biased toward that specific terrain or crop type rather than testing true Model Generalization.


C. Preview image-mask pairs

Each sample pair displays the Sentinel-2 imagery next to its instance mask. In the mask, each distinct color represents an individual field instance (e.g., 1,2,3,…1, 2, 3, \dots), preserving unique object identities rather than simply labeling all agricultural pixels as a single class.

When inspecting samples, perform these manual quality checks:


D. Prepare data for training

Before passing data to the Mask R-CNN training pipeline, prepare_ftw() handles data rescaling and directory structuring:

The preparation pipeline executes four main tasks:

raw FTW imagery (16-bit reflectance, 0-10'000)
                   ↓
   rescale values to 8-bit (0-255 uint8)
                   ↓
organize into standard directory layout (images/ + labels/)
                   ↓
   pool dev chips & reserve test set for inference
  1. Reflectance Rescaling: Converts raw Sentinel-2 16-bit reflectance values (0 - 10’000) to the 8-bit uint8 range (0 - 255) expected by the underlying geoai Mask R-CNN framework. (Note: This conversion is a specific pipeline requirement for this teaching workflow, not a general rule for all remote sensing tasks).

  2. Directory Formatting: Places paired GeoTIFF tiles into standardized subfolders:

field_boundaries/
├── images/
└── labels/
  1. Split Reorganization: Combines the official FTW training and validation chips into a single 724-chip development pool, while reserving a small, independent test set exclusively for inference demonstrations. An internal validation split (20%20\%) is automatically created from the development pool during model training on the next page.


E. Verify prepared training tiles

Always inspect the formatted output files before starting a long training run to catch preprocessing errors early:

During this inspection, confirm:


4. Python reactivation

Path("ftw_data") / "luxembourg" uses pathlib’s / operator to join path components, a cleaner alternative to os.path.join() for the same purpose. gpd.read_parquet() reads a GeoParquet file into a GeoDataFrame, the same object type you have used throughout the course for vector data, just stored in a different, more compact file format than GeoJSON or Shapefile. chips_gdf["split"].value_counts() counts how many rows fall into each unique value of the split column, a quick way to check a dataset’s class or split balance.


5. Common pitfalls


6. Mini task

prepare_ftw() reported “FTW luxembourg: 808 total chips, Train: 643, Val: 81, Test: 84” and “Using 724 chips for training.” Without running any code, explain where the number 724 comes from, and what happens to the 84 test chips mentioned in the first line versus the smaller number prepare_ftw() actually sets aside for testing in this tutorial.

Sample solution

724 is the sum of the official training (643) and validation (81) chips, combined into a single development pool: 643 + 81 = 724. The official split reserves 84 chips for testing, but the tutorial workflow only prepares a small subset of those (5, as shown in the accompanying preparation output) to keep the tutorial lightweight and fast to run; a production workflow would likely use more, or all, of the 84 official test chips for a more robust final evaluation.


7. Key takeaways

Further reading