stackstac.array_bounds¶
-
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 thex
andy
coordinates.- Parameters
arr (
DataArray
) –The
DataArray
must either have aRasterSpec
as thespec
attribute (preferred), or the coordinatesx
andy
.The
x
andy
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, theDataArray
must have anepsg
coordinate.
- Returns
Bounds of the
DataArray
, as a 4-tuple.- Return type
Bbox
- Raises
ValueError: – If the
DataArray
has nospec
attribute.ValueError: – If the
DataArray
is missing thex
ory
coordinates.ValueError: – If
x
ory
coordinates are not monotonic.ValueError: – If
to_epsg
is given, and the CRS of the~xarray.DataArray
cannot be determined byarray_epsg
.