8000 Return correct dims of rotated grid constructed from geom by savente93 · Pull Request #1153 · Deltares/hydromt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Return correct dims of rotated grid constructed from geom #1153

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

Merged
merged 4 commits into from
Apr 2, 2025

Conversation

savente93
Copy link
Contributor
@savente93 savente93 commented Apr 2, 2025

Issue addressed

Fixes #1121

Explanation

As mentioned the rotated grid creation returned the dimensions flipped as was reported in the docstring. I added a simple test to solidfy which shapes we should return here

General Checklist

  • Updated tests or added new tests
  • Branch is up to date with main
  • Tests & pre-commit hooks pass
  • Updated documentation
  • Updated changelog.rst

Data/Catalog checklist

  • data/catalogs/predefined_catalogs.yml has not been modified.
  • None of the old data_catalog.yml files have been changed
  • data/changelog.rst has been updated
  • new file uses LF line endings (done automatically if you used update_versions.py)
  • New file has been tested locally
  • Tests have been added using the new file in the test suite

Additional Notes (optional)

Add any additional notes or information that may be helpful.

@savente93 savente93 requested a review from dalmijn April 2, 2025 10:13
Copy link
Contributor
@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bugfix, LGTM.
Two small remarks.

Comment on lines 14 to 15
from shapely import Polygon
from shapely.geometry import LineString, Point, box
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are there two separate import statements here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was an auto import, I merged it with the next one

Comment on lines 574 to 582
def test_create_rotated_grid_from_geom():
coords = [(0, 0), (10, 0), (10, 100), (0, 100), (0, 0)]
polygon = Polygon(coords)

# Create a GeoDataFrame
region = gpd.GeoDataFrame(pd.DataFrame({"id": [1]}), geometry=[polygon])
da = create_rotated_grid_from_geom(region, res=1, dec_origin=0, dec_rotation=0)
expected_shape = (100, 10)
assert da.raster.shape == expected_shape
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in a regular grid, I guess the point is to test for rotated grids, so maybe add a rotated square as input geometry?

Copy link
sonarqubecloud bot commented Apr 2, 2025

Copy link
Contributor
@dalmijn dalmijn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very rotated, very good.

@savente93 savente93 merged commit f5b00ad into main Apr 2, 2025
25 checks passed
@savente93 savente93 deleted the fix-rotated-grid-dims branch April 2, 2025 12:51
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.

Unexpected behaviour in raster.full_from_transform
2 participants
0