Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 18, 2023
1 parent 72bcb31 commit 4ec57f6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions odc/geo/_xr_interop.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ def crop(xx: XrT, poly: Geometry, mask: bool = True, all_touched: bool = True) -
raise ValueError(
"The supplied `poly` must overlap spatially with the extent of `xx`."
)

# Identify spatial dims and raise error if None
sdims = spatial_dims(xx)
if sdims is None:
raise ValueError("Can't locate spatial dimensions")

# Crop `xx` to the bounding box of `poly`. First create new geobox
# with the same pixel grid as `xx` but enclosing `poly`. Then
# with the same pixel grid as `xx` but enclosing `poly`. Then
# calculate slices into `xx` for the intersection between both geoboxes.
roi = xx.odc.geobox.overlap_roi(xx.odc.geobox.enclosing(poly))
xx_cropped = xx.isel({sdims[0]: roi[0], sdims[1]: roi[1]})
Expand Down

0 comments on commit 4ec57f6

Please sign in to comment.