Skip to content

Data Sources — Overview

All data sources inherit from DataSource and implement a single method:

def fetch(self, grid: GridSpec | None = None) -> RasterData:
    ...

RasterData is a named tuple (array: np.ndarray, crs: str | None, transform: Affine | None). No rasterio objects are ever exposed outside a source module.

Source catalogue

Source Use case
ArraySource In-memory numpy array
ConstantSource Single scalar broadcast over the grid
RasterSource Local GeoTIFF file
URLSource Remote GeoTIFF via HTTP
WCSSource Generic OGC WCS endpoint
PointGridSource Sample any callable over an N×N lat/lon grid

Grid-aware vs self-contained sources

Self-contained sources (ArraySource, ConstantSource, RasterSource, URLSource) ignore the grid argument. They carry their own spatial metadata.

Grid-aware sources need the reference grid to determine what geographic area to query. They call grid.extent_wgs84() to obtain (lon_min, lat_min, lon_max, lat_max) before making API or WCS requests.

Grid-aware sources are: WCSSource, PointGridSource.

DataSource ABC

DataSource

Bases: ABC

Base class for all geographic data sources.

Every source returns a plain RasterData tuple (array, crs, transform) — no rasterio objects are ever exposed outside the source module.

fetch abstractmethod

fetch(grid=None)

Fetch data aligned to grid if provided.

Parameters

grid: Reference grid context. Required by sources that need to know the spatial domain before querying (e.g. OpenMeteoSource). Ignored by sources that are self-contained (Array, Raster, URL, Constant).