stackstac.array_bounds#
- stackstac.array_bounds(arr, to_epsg=None)#
Get the bounds of a
DataArray.The bounds are either taken from the
specattribute, or computed from thexandycoordinates.- Parameters:
The
DataArraymust either have aRasterSpecas thespecattribute (preferred), or the coordinatesxandy.The
xandycoordinates 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, theDataArraymust have anepsgcoordinate.
- Returns:
Bounds of the
DataArray, as a 4-tuple.- Return type:
Bbox
- Raises:
ValueError: – If the
DataArrayhas nospecattribute.ValueError: – If the
DataArrayis missing thexorycoordinates.ValueError: – If
xorycoordinates are not monotonic.ValueError: – If
to_epsgis given, and the CRS of the~xarray.DataArraycannot be determined byarray_epsg.