Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour in raster.full_from_transform #1121

Open
2 tasks done
roeldegoede opened this issue Feb 20, 2025 · 0 comments
Open
2 tasks done

Unexpected behaviour in raster.full_from_transform #1121

roeldegoede opened this issue Feb 20, 2025 · 0 comments
Labels
Bug Something isn't working Needs refinement issue still needs refinement

Comments

@roeldegoede
Copy link
Contributor

HydroMT version checks

  • I have checked that this issue has not already been reported.
  • I have checked that this bug exists on the latest version of HydroMT.

Reproducible Example

According to the documentation of raster.full_from_transform, the shape is defined as "Length along (dim0, x, y) dimensions, of which the first is optional" whereas it returns a DataArray with dimensions y, x (hence flipped).

When calling this function like this, where the mmax is nr of cells in x-direction, and nmax the nr of cells in y-direction, like is done in hydromt.model.processes.grid.create_grid_from_region.

raster.full_from_transform(
        transform,
        shape=(mmax, nmax),
        nodata=1,
        dtype=np.uint8,
        name="mask",
        attrs={},
        crs=geom.crs,
        lazy=False,
    )

Current behaviour

This returns a raster with dimensions mmax by nmax (hence x, y) and not y, x!

Desired behaviour

To properly work, we should change the code into:

raster.full_from_transform(
        transform,
        shape=(nmax, mmax),
        nodata=1,
        dtype=np.uint8,
        name="mask",
        attrs={},
        crs=geom.crs,
        lazy=False,
    )

and change the description of full_from_transform in raster.py

Additional context

No response

@roeldegoede roeldegoede added Bug Something isn't working Needs refinement issue still needs refinement labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Needs refinement issue still needs refinement
Projects
None yet
Development

No branches or pull requests

1 participant