stackstac.array_bounds(arr, to_epsg=None)#

Get the bounds of a DataArray.

The bounds are either taken from the spec attribute, or computed from the x and y coordinates.

  • arr (DataArray) –

    The DataArray must either have a RasterSpec as the spec attribute (preferred), or the coordinates x and y.

    The x and y coordinates are assumed to indicate the top-left corner of each pixel, not the center. They’re also assumed to be evenly spaced (constant resolution), and must be monotonic.

  • to_epsg (Optional[int]) – CRS to reproject the bounds to, as an EPSG code. If None (default), the bounds are not reprojected. If not None, the DataArray must have an epsg coordinate.


Bounds of the DataArray, as a 4-tuple.

Return type:


  • ValueError: – If the DataArray has no spec attribute.

  • ValueError: – If the DataArray is missing the x or y coordinates.

  • ValueError: – If x or y coordinates are not monotonic.

  • ValueError: – If to_epsg is given, and the CRS of the ~xarray.DataArray cannot be determined by array_epsg.