Skip to main content
Public Preview

A mosaic is one continuous raster image of an area of interest (AOI) for a time range, made by combining many overlapping satellite or aerial scenes. RasterFlow puts the scenes onto one pixel grid. Where scenes overlap, each dataset has its own rule for choosing the pixel value, such as the median of the observations left after cloud and quality masking (s2_median) or the valid scene closest to a date (s2_closest_valid). The build_mosaics task builds mosaics from the built-in datasets, such as Sentinel-2 and NAIP, and writes each one as a Zarr store. To build mosaics from your own imagery, use build_gti_mosaics, described in Bring your own rasters.
The examples on this page run RasterFlow through the Tasks API, in two tabs. Python uses the Wherobots Python SDK, and API calls the REST API with curl. Outside a Wherobots notebook or job, both need a Wherobots API key in WHEROBOTS_API_KEY. Each example starts a task run; to wait for it and read its results, see Get started and Run RasterFlow Tasks.

Build a mosaic

Pass build_mosaics the datasets to use, an AOI in aoi, a time range in start and end, and the output grid’s CRS in target_crs. Areas of interest lists the formats aoi accepts, and RasterFlow Datasets lists the datasets values and their time rules. This example builds 2023 planting- and harvest-season composites for Haskell County, Kansas:
The run’s output, mosaic_index_uri, is a mosaic index that lists the Zarr stores the run wrote.

Build mosaics for several areas in one run

build_mosaics builds one mosaic for each row of an AOI file. To build mosaics for several separate areas in one task run, write each area as its own row of a GeoParquet file, then pass the file’s URI in aoi. This sample writes three areas of about 2 km × 2 km to your Managed Storage. All three are in UTM zone 18N, so one target_crs fits them all. The geometries carry SRID 4326, which the GeoParquet writer records as the file’s CRS.
Python
Pass the file to build_mosaics:
The mosaic index has one row for each AOI row. It keeps the AOI file’s columns, here name and geometry, and adds aoi_coverage_percent and the store’s URI in location. The sample prints:
Tasks that read a mosaic, such as build_zarr_multiscales, take one store per run, so start one run for each value in location.

Areas in different UTM zones

The sample above passes one target_crs because all three areas are in UTM zone 18N. For areas in different zones, leave out target_crs and give each row its own output CRS: an integer EPSG code in a column named crs:epsg. The colon in the name needs backticks in SQL. crs:epsg sets only the output grid. The geometries stay in longitude and latitude, so they keep SRID 4326. This sample writes one area in UTM zone 18N and one in UTM zone 13N:
Python
Pass the file to build_mosaics without target_crs:
The run writes one store for each row, in that row’s CRS: UTM zone 18N for College Park and UTM zone 13N for Denver. The mosaic index keeps the crs:epsg column. Set the output CRS one way, not both. If you pass target_crs for an AOI file that has a crs:epsg column, the run fails with CRS provided both in AOI and as argument. Pick one.

Build one mosaic across several areas

A MULTIPOLYGON is one geometry made of several separate polygons, such as a farm’s fields or a group of islands stored as one feature. In WKT, it lists each polygon in its own set of parentheses: MULTIPOLYGON (((…)), ((…))). A MULTIPOLYGON fills one row of an AOI file, so build_mosaics builds one mosaic for it. That mosaic’s grid covers the bounding box of all the parts: the smallest rectangle that contains every polygon, including the space between them. To build separate mosaics without the space between them, write each part as its own row.

Next steps