Skip to content

Commit 59a5269

Browse files
committed
Fix notebook errors
1 parent ce25309 commit 59a5269

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

docs/advanced_stress_packages/01_lake.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"mask = lak_grid.area > 0.5 * ds[\"area\"].sel(icell2d=lak_grid.index)\n",
182182
"lak_grid = lak_grid[mask]\n",
183183
"# set the geometry to the entire cell\n",
184-
"gi = flopy.utils.GridIntersect(nlmod.grid.modelgrid_from_ds(ds), method=\"vertex\")\n",
184+
"gi = flopy.utils.GridIntersect(nlmod.grid.modelgrid_from_ds(ds))\n",
185185
"lak_grid.geometry = gi.geoms[lak_grid.index]\n",
186186
"\n",
187187
"# remove drains that overlap with the lake\n",

nlmod/dims/grid.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

24452445
def 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

Comments
 (0)