stackstac.reproject_array#
- stackstac.reproject_array(arr, spec, interpolation='nearest', fill_value=nan)#
Reproject and clip a
DataArrayto a newRasterSpec(CRS, resolution, bounds).This interpolates using
xarray.DataArray.interp, which usesscipy.interpolate.interpninternally (no GDAL). It is somewhat dask-friendly, in that it at least doesn’t trigger immediate computation on the array, but it’s sub-optimal: thexandydimensions are just merged into a single chunk, then interpolated.Since this both eliminates spatial parallelism, and potentially requires significant amounts of memory,
reproject_arrayis only recommended on arrays with a relatively small number spatial chunks.Warning
This method is very slow on large arrays due to inefficiencies in generating the dask graphs. Additionally, all spatial chunking is lost.
- Parameters:
arr (
DataArray) – Array to reproject. It must haveepsg,x, andycoordinates. Thexandycoordinates are assumed to indicate the top-left corner of each pixel, not the center.spec (
RasterSpec) – TheRasterSpecto reproject to.interpolation (
Literal[‘linear’, ‘nearest’]) – Interpolation method:"linear"or"nearest", default"nearest".fill_value (
Union[int,float,None]) – Fill output pixels that fall outside the bounds ofarrwith this value (default NaN).
- Returns:
The clipped and reprojected array.
- Return type: