Skip to content

Commit

Permalink
check if the Y bounds are inverted and flip the image on the Y axis
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Oct 24, 2024
1 parent 3909c6a commit af9af80
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rio_tiler/io/xarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def tile(
arr = ds.to_masked_array()
arr.mask |= arr.data == ds.rio.nodata

output_bounds = ds.rio._unordered_bounds()
if output_bounds[1] > output_bounds[3] and ds.rio.transform().e > 0:
arr = arr[..., ::-1, :]

return ImageData(
arr,
bounds=tile_bounds,
Expand Down Expand Up @@ -305,6 +309,10 @@ def part(
arr = ds.to_masked_array()
arr.mask |= arr.data == ds.rio.nodata

output_bounds = ds.rio._unordered_bounds()
if output_bounds[1] > output_bounds[3] and ds.rio.transform().e > 0:
arr = arr[..., ::-1, :]

img = ImageData(
arr,
bounds=ds.rio.bounds(),
Expand Down Expand Up @@ -387,6 +395,10 @@ def preview(
arr = ds.to_masked_array()
arr.mask |= arr.data == ds.rio.nodata

output_bounds = ds.rio._unordered_bounds()
if output_bounds[1] > output_bounds[3] and ds.rio.transform().e > 0:
arr = arr[..., ::-1, :]

img = ImageData(
arr,
bounds=ds.rio.bounds(),
Expand Down Expand Up @@ -523,6 +535,10 @@ def feature(
arr = ds.to_masked_array()
arr.mask |= arr.data == ds.rio.nodata

output_bounds = ds.rio._unordered_bounds()
if output_bounds[1] > output_bounds[3] and ds.rio.transform().e > 0:
arr = arr[..., ::-1, :]

img = ImageData(
arr,
bounds=ds.rio.bounds(),
Expand Down

0 comments on commit af9af80

Please sign in to comment.