build_gti_mosaics function.
What you will learn
This notebook will teach you to:- Query a STAC catalog to discover available imagery for an area of interest
- Create a GTI (GDAL Raster Tile Index) from STAC items
- Build a seamless mosaic from multiple image tiles using RasterFlow’s
build_gti_mosaics - Visualize the resulting mosaic and inference outputs
- (Optional) Run road detection using the ChesapeakeRSC model
NAIP (National Agriculture Imagery Program)
The National Agriculture Imagery Program (NAIP) acquires aerial imagery during the agricultural growing seasons in the continental United States. Key characteristics:- Resolution: 1 meter ground sample distance
- Bands: 4-band imagery (Red, Green, Blue, NIR) in a single COG file
- Coverage: Continental United States
- Update cycle: Typically every 2-3 years per state
Setup and Imports
Selecting an Area of Interest (AOI)
We will use Montgomery County, Maryland as our AOI. This county is well-covered by NAIP imagery and provides a good example for demonstrating the BYOR workflow.Loading the NAIP STAC collection
We use Wherobots’ built-in STAC reader to load the NAIP collection from Element84’s Earth Search catalog. This catalog provides direct S3 URLs to the imagery files.Applying spatial and temporal filters
We filter the NAIP collection to only include tiles that:- Intersect with our AOI (Montgomery County)
- Were captured in 2017 (the most recent year with 1-meter resolution NAIP imagery available for Maryland so we can test the ChesapeakeRSC model)
Exploring the STAC asset structure
Before creating the GTI, we need to understand the structure of the STAC assets. NAIP stores all 4 bands (RGBIR) in a single COG file, so we only need one row per tile in our GTI.Creating the GTI (GDAL Raster Tile Index)
The GTI is a spatial index that maps tile geometries to their corresponding COG URLs. For more information on GTI, see the reference documentation. Since NAIP has a single 4-band COG per tile, we create one row per tile.Saving the GTI as GeoParquet
We convert the Spark DataFrame to a GeoDataFrame and save it as GeoParquet for use with RasterFlow.Verifying the GTI
Before building the mosaic, we verify that the GTI was saved correctly and visualize the tile footprints.Building a mosaic with RasterFlow
Now we use RasterFlow’sbuild_gti_mosaics function to create a seamless 4-band mosaic from the NAIP tiles.
Note: TheExpected runtime: ~5-10 minutes depending on the number of tiles.naip-analyticS3 bucket is requester-pays, so we setrequester_pays=True.
(Optional) Build an optimized Zarr for visualization
RasterFlow writes its outputs as Zarr stores at native resolution. To explore them interactively on cloud.wherobots.com/map, you can build an optimized multiscale Zarr.build_zarr_multiscales adds downsampled overview levels (image pyramids) to the store so the map can stream coarse tiles when zoomed out and full-resolution pixels when zoomed in.
This step is optional and can take a few minutes for large outputs, so the code below is commented out by default — uncomment it to run it.
Visualizing outputs
If RasterFlow is enabled for your organization, you can visualize the mosaic and inference outputs from this notebook using cloud.wherobots.com/map. Zarr, GeoParquet, and other geospatial data formats are supported, so you can inspect either the mosaic output or the road-probability output from the preceding workflow steps.(Optional) Running inference with ChesapeakeRSC
Now that we have built the NAIP mosaic, we can optionally run a semantic segmentation model to detect roads. The ChesapeakeRSC model was trained on NAIP imagery from Maryland and can detect roads even when occluded by tree cover. The model outputs two classes:backgroundroad

