stackstac.reproject_array(arr, spec, interpolation='nearest', fill_value=nan)#

Reproject and clip a DataArray to a new RasterSpec (CRS, resolution, bounds).

This interpolates using xarray.DataArray.interp, which uses scipy.interpolate.interpn internally (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: the x and y dimensions are just merged into a single chunk, then interpolated.

Since this both eliminates spatial parallelism, and potentially requires significant amounts of memory, reproject_array is only recommended on arrays with a relatively small number spatial chunks.


This method is very slow on large arrays due to inefficiencies in generating the dask graphs. Additionally, all spatial chunking is lost.

  • arr (DataArray) – Array to reproject. It must have epsg, x, and y coordinates. The x and y coordinates are assumed to indicate the top-left corner of each pixel, not the center.

  • spec (RasterSpec) – The RasterSpec to 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 of arr with this value (default NaN).


The clipped and reprojected array.

Return type: