@@ -1347,12 +1347,12 @@ def polygon_to_area(modelgrid, polygon, da, gridtype="structured"):
13471347 df = ix .intersect (polygon , geo_dataframe = True )
13481348
13491349 if gridtype == "structured" :
1350- area_array = util .get_da_from_da_ds (da , dims = ("y" , "x" ), data = 0 )
1350+ area_array = util .get_da_from_da_ds (da , dims = ("y" , "x" ), data = 0.0 )
13511351 for row , col , area in zip (df ["row" ], df ["col" ], df ["areas" ]):
13521352 area_array [row , col ] = area
13531353 elif gridtype == "vertex" :
1354- area_array = util .get_da_from_da_ds (da , dims = ("icell2d" ,), data = 0 )
1355- area_array [df ["cellid" ]] = df ["areas" ]
1354+ area_array = util .get_da_from_da_ds (da , dims = ("icell2d" ,), data = 0.0 )
1355+ area_array [df ["cellid" ]. values ] = df ["areas" ]
13561356
13571357 return area_array
13581358
@@ -2443,6 +2443,22 @@ def get_extent_polygon(ds, rotated=True):
24432443
24442444
24452445def get_extent_gdf (ds , rotated = True , crs = "EPSG:28992" ):
2446+ """Get the model extent as a GeoDataFrame with a polygon.
2447+
2448+ Parameters
2449+ ----------
2450+ ds : xr.Dataset
2451+ model dataset.
2452+ rotated : bool, optional
2453+ if True, the extent is corrected for angrot. The default is True.
2454+ crs : str, optional
2455+ Coordinate reference system. The default is "EPSG:28992".
2456+
2457+ Returns
2458+ -------
2459+ gdf : geopandas.GeoDataFrame
2460+ GeoDataFrame containing the model extent as a polygon geometry.
2461+ """
24462462 polygon = get_extent_polygon (ds , rotated = rotated )
24472463 return gpd .GeoDataFrame (geometry = [polygon ], crs = crs )
24482464
0 commit comments