From 90e2e685e1a1dcf8677b4893b576a2d5e81fd101 Mon Sep 17 00:00:00 2001 From: roeldegoede <83765910+roeldegoede@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:32:20 +0100 Subject: [PATCH] bugfix in workflows.bathymetry (for burning in rivers) (#166) * bugfix in workflows.bathymetry (for burning in rivers) * update changelog --- docs/changelog.rst | 1 + hydromt_sfincs/workflows/bathymetry.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 31c6c376..161c83b9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -23,6 +23,7 @@ Fixed - fixed `SfincsModel.setup_subgrid` for models with geograpgical CRS (#152) - fixed masking of elevation and manning datasets when providing mask attribute (#153) - fix a bug that caused some model files to be read twice (#161) +- bugfix in workflows.bathymetry that was encountered while burning in rivers (#166) Deprecated ---------- diff --git a/hydromt_sfincs/workflows/bathymetry.py b/hydromt_sfincs/workflows/bathymetry.py index 9f01df98..f4e3e010 100644 --- a/hydromt_sfincs/workflows/bathymetry.py +++ b/hydromt_sfincs/workflows/bathymetry.py @@ -155,7 +155,7 @@ def interp_along_line_to_grid( gdf_zb = gdf_zb[["geometry"] + column_names].copy() gdf_zb["idx0"], gdf_zb["dist"] = nearest(gdf_zb, gdf_lines) nearest_lines = gdf_lines.loc[gdf_zb["idx0"], "geometry"].values - gdf_zb["x"] = nearest_lines.project(gdf_zb["geometry"]) + gdf_zb["x"] = nearest_lines.project(gdf_zb["geometry"].values) gdf_zb.set_index("idx0", inplace=True) # keep only lines with associated points gdf_lines = gdf_lines.loc[np.unique(gdf_zb.index.values)] @@ -163,7 +163,7 @@ def interp_along_line_to_grid( # find nearest line and calculate relative distance along line for all cell centers cc["idx0"], cc["dist"] = nearest(cc, gdf_lines) nearest_lines = gdf_lines.loc[cc["idx0"], "geometry"].values - cc["x"] = nearest_lines.project(cc["geometry"].to_crs(gdf_lines.crs)) + cc["x"] = nearest_lines.project(cc["geometry"].to_crs(gdf_lines.crs).values) # interpolate z values per line def _interp(cc0, gdf_zb=gdf_zb, column_names=column_names):