Skip to content

Fetch and stream grid data

You are viewing in-progress documentation for v2. Switch to the stable version for the current production release.

A grid’s raster values are read back per band, per chunk. Large grids are tiled into chunks so you can stream them without pulling the whole array at once. You fetch each chunk and place it into the full array using the chunk’s offset. This guide walks that loop.

  1. An API key: my-api-key.

  2. A domain and a completed grid: your-domain-id and your-grid-id — e.g. the fuel-load grid from Build a surface fuel grid from LANDFIRE.

GET the grid. Two fields drive the rest: georeference.shape (the full (height, width)) and chunks.count (how many chunks to fetch per band).

GET grid
curl -X 'GET' \
'https://api.fastfuels.silvxlabs.com/v2/domains/your-domain-id/grids/your-grid-id' \
-H 'accept: application/json' \
-H 'api-key: my-api-key'

bands lists the band keys you can request. chunks.count here is 1 (this grid fits in a single tile). A larger grid reports more, laid out count_by_axis.

GET /grids/{{GRID_ID}}/data/{band}/{chunk_index}. The response carries the chunk’s own shape, an offset into the full array, the chunk’s affine transform, and the values.

GET data/fuel_load.1hr/0
curl -X 'GET' \
'https://api.fastfuels.silvxlabs.com/v2/domains/your-domain-id/grids/your-grid-id/data/fuel_load.1hr/0' \
-H 'accept: application/json' \
-H 'api-key: my-api-key'

data.values is the chunk data — a flat array of shape[0] × shape[1] values in order ("C", row-major). It’s shown abridged above. The full chunk here is 30 × 45 = 1350 floats. Two formats:

  • dense (the default) — values holds every cell, in order.
  • sparse — request it with ?array_format=sparse. values holds only the cells that differ from the band’s fill_value, paired with indices. Reconstruct by filling with fill_value then scattering values into indices. Sparse shrinks chunks that are mostly fill, and it can let an oversized chunk fit under the response size limit.

The SDK does the per-chunk loop for you. grid.to_numpy(band) fetches every chunk, handles dense vs sparse, and places each at its offset — returning the full (height, width) array ((z, y, x) for a voxel grid). grid.to_xarray() returns every band as a georeferenced xarray.Dataset, with x/y coordinates derived from the grid’s affine transform.

Read every band into an xarray.Dataset
import fastfuels_sdk.v2 as ff
ff.set_api_key("my-api-key")
grid = ff.get_grid("your-domain-id", "your-grid-id")
# Every band at once as a georeferenced xarray.Dataset, with x / y coordinate
# vectors derived from the grid's affine transform and the CRS on the dataset.
dataset = grid.to_xarray()

Over raw HTTP with curl, loop chunk_index from 0 to chunks.count - 1 and position each chunk by its metadata.offset, as the responses above show.

These apply when you fetch over raw HTTP (the curl path). The SDK’s to_numpy() / to_xarray() handle band iteration, chunk offsets, and the dense/sparse formats for you.

  • Forgetting it’s per band. Each data/{band}/{chunk_index} call returns one band. Loop over bands (from step 1) as well as over chunks.
  • Ignoring offset. Concatenating chunks in fetch order mis-places them. Always position a chunk with its metadata.offset — that’s what makes the reassembled array correct for multi-chunk grids.
  • Assuming a format. The response format follows the array_format you request (dense by default), and every chunk comes back in that format. Branch on data.format if your code requests sparse anywhere, so the reassembly handles both shapes.
  • Grid not completed. Data is only readable once the grid finishes. chunks.count is null until the grid is completed, and a data request before then returns 404.