Skip to content

Commit

Permalink
Removed logging empty gdf and no union for singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
bdestombe committed Dec 23, 2024
1 parent 7d0ae65 commit ad2c9e6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions nlmod/dims/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1664,12 +1664,13 @@ def gdf_to_bool_da(
msg = "gdf_to_bool_da() only support structured or vertex gridtypes"
raise ValueError(msg)

if len(gdf) == 0:
logger.warning("gdf passed to gdf_to_bool_da() is empty")
return da

if isinstance(gdf, gpd.GeoDataFrame):
multipolygon = unary_union(gdf.geometry)
if len(gdf) == 0:
return da
elif len(gdf) == 1:
multipolygon = gdf.geometry.values[0]
else:
multipolygon = unary_union(gdf.geometry)
elif isinstance(gdf, shapely.geometry.base.BaseGeometry):
multipolygon = gdf
else:
Expand Down

0 comments on commit ad2c9e6

Please sign in to comment.