xrspatial.preview.preview#
- xrspatial.preview.preview(agg, width=1000, height=None, method='mean', name='preview')[source]#
Downsample a raster to target pixel dimensions.
For dask-backed arrays, the operation is lazy: each chunk is reduced independently, so peak memory is bounded by the largest chunk plus the small output array. A 30 TB raster can be previewed at 1000x1000 with only a few MB of RAM.
- Parameters:
agg (xr.DataArray) – Input raster (2D).
width (int, default 1000) – Target width in pixels.
height (int, optional) – Target height in pixels. If not provided, computed from width preserving the aspect ratio of agg.
method (str, default 'mean') –
Downsampling method. One of:
'mean': block averaging.'median': block median.'max': block maximum.'min': block minimum.'nearest': stride-based subsampling (fastest, no smoothing).'bilinear': bilinear interpolation viascipy.ndimage.zoom.
name (str, default 'preview') – Name for the output DataArray.
- Returns:
Downsampled raster with updated coordinates.
- Return type:
xr.DataArray