Skip to content

BUG: Handle negative and scalar resolution in merge_arrays - #967

Open
lyn1dev wants to merge 1 commit into
vylor:masterfrom
lyn1dev:fix-merge-negative-res
Open

lyn1dev wants to merge 1 commit into
vylor:masterfrom
lyn1dev:fix-merge-negative-res

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 25, 2026 •

Copy link
Copy Markdown

Normalize res in merge_arrays to positive (xres, yres) values before comparing against dataarray.rio.resolution() and forwarding res to rasterio.merge.merge.

Previously, passing res=da.rio.resolution() (which has a negative y-resolution for north-up rasters) or a scalar res caused two issues:

  1. da_res != res always evaluated to True, triggering an unnecessary reproject even when the resolution already matched.
  2. input_kwargs["res"] preserved the negative y-resolution and passed it into rasterio.merge.merge, resulting in a negative output height (ValueError: negative dimensions are not allowed / ValueError: Number of columns or rows must be non-negative).

AI was used to write this code.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative dimensions in merge arrays

1 participant