Skip to content

Commit

Permalink
Rotate the polygon instead of the modelgrid
Browse files Browse the repository at this point in the history
  • Loading branch information
bdestombe committed Dec 23, 2024
1 parent ad2c9e6 commit e8d47cc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nlmod/dims/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1680,9 +1680,17 @@ def gdf_to_bool_da(
if buffer != 0.0:
multipolygon = multipolygon.buffer(buffer)

# Rotate the polygon instead of the modelgrid
if ix is None:
modelgrid = modelgrid_from_ds(ds)
modelgrid = modelgrid_from_ds(ds, rotated=False)
ix = GridIntersect(modelgrid, method="vertex")

grid_rotation = ds.attrs.get("angrot", 0.0)
ix_rotation = ix.mfgrid.angrot

if grid_rotation != 0.0 and ix_rotation == 0.0:
affine = get_affine_mod_to_world(ds)
multipolygon = affine_transform_gdf(multipolygon, affine)

if kwargs or contains_centroid or min_area_fraction is not None:
r = ix.intersect(
Expand Down

0 comments on commit e8d47cc

Please sign in to comment.