Skip to main content
Public Preview
The following content is a read-only preview of an executable Jupyter notebook.To run this notebook interactively:
  1. Go to Models in Wherobots Cloud.
  2. Select the model whose notebook you wish to run.
  3. Click Try it, select the Solution notebook tab, then click Open the solution notebook.
chm banner This notebook will guide you through estimating canopy height from aerial imagery, using Wherobots RasterFlow and the Meta and World Resources Institute’s Canopy Height prediction model (Meta CHM v1)1. This is an open source regression model that can predict the height of the tree canopy from high resolution imagery. The result of the model is a raster where each pixel is the estimated tree canopy height in meters. It was trained on high-resoluton imagery (Maxar Vivid2 mosaic with 0.5m resolution), existing labeled canopy height maps and airborne laser scans (LIDAR).

Running inference on high resolution imagery

The Meta CHM v1 model was trained on 50cm resolution data, so we will select imagery with a similar resolution for our testing. The National Agriculture Imagery Program (NAIP) provides aerial imagery for the United States, capturing high-resolution images during the agricultural growing seasons. The NAIP dataset contains a mixture of resolutions (30cm, 60cm and 1m).

Preview: model inputs and outputs

The interactive map linked below shows the input imagery and model outputs for this notebook’s example AOI. Toggle layers in the sidebar to compare the input mosaic and the raster model output side-by-side. Layers (top layer first, as in the map’s layer list):
  • CHM model outputs: Single-band raster where each pixel is the estimated tree canopy height in meters
  • CHM input mosaic: RGB NAIP aerial imagery the model runs on
View the interactive map here.

Selecting an Area of Interest (AOI)

We will choose an Area of Interest (AOI) for our analysis. The area around Nashua, NH has a combination of urban settings, parks and forests so we will try out the model there.

Selecting a time range and verifying NAIP coverage

NAIP is flown state by state on a multi-year cycle, and the Meta CHM v1 recipe sources 60cm imagery. The most recent 60cm imagery for New Hampshire was captured in 2021, so we will set our time range accordingly. If you change the AOI or the time range, the 60cm imagery the model needs may not exist. The USDA’s NAIP coverage map (PDF, 2002-2025) shows what is available where.

Using the Wherobots Tasks API

Each RasterFlow workflow runs as a task through the Wherobots Python SDK. run_task below starts a task run, waits for it to finish, and returns its output value. Recipes return an object with input_mosaic and result; standalone tasks return a URI. Call wb.tasks.get("<task name>").input_schema to see every input a task accepts.

Running a model

RasterFlow has pre-defined workflows to simplify orchestration of the processing steps for model inference. These steps include:
  • Ingesting imagery for the specified Area of Interest (AOI)
  • Generating a seamless image from multiple image tiles (a mosaic)
  • Running inference with the selected model
The recipe returns input_mosaic for the source imagery and result for the predictions. Each contains a mosaic_index_uri for its GeoParquet index and a first_row_mosaic for its first Zarr store. Note: This step will take approximately 20 minutes to complete.

(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. Pass aoi to select a chunk-aligned bounding window from a single Zarr source. It accepts polygon or multipolygon WKT in EPSG:4326, or an S3 GeoJSON or GeoParquet URI with a CRS. Pixels outside the polygon remain within that rectangular window. Omit aoi to process the full store.

Visualizing outputs

You can visualize the Zarr, GeoParquet, and other geospatial outputs using cloud.wherobots.com/map.

References

  1. Tolan, J., Yang, H.-I., Nosarzewski, B., Couairon, G., Vo, H. V., Brandt, J., Spore, J., Majumdar, S., Haziza, D., Vamaraju, J., et al. (2024). Very high resolution canopy height maps from RGB imagery using self-supervised vision transformer and convolutional decoder trained on aerial lidar. Remote Sensing of Environment, 300, 113888.