Skip to content

Commit

Permalink
bugfix in workflows.bathymetry (for burning in rivers) (#166)
Browse files Browse the repository at this point in the history
* bugfix in workflows.bathymetry (for burning in rivers)

* update changelog
  • Loading branch information
roeldegoede authored Dec 22, 2023
1 parent 35f2db3 commit 90e2e68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
4 changes: 2 additions & 2 deletions hydromt_sfincs/workflows/bathymetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ 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)]

# 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):
Expand Down

0 comments on commit 90e2e68

Please sign in to comment.