Skip to content

Commit

Permalink
using z-value in floodwall from shp file (#427)
Browse files Browse the repository at this point in the history
* using z-value in floodwall from shp file and convertin MultiLineString to LineString

* black

* addressing review comments

* address review comment: convert also z-values from shape file

* fixed unit conversion

* black

* include logging statement when height from shape file cannot be read

* black

* include positive logging info when height from shape is used
  • Loading branch information
GundulaW authored Apr 29, 2024
1 parent bb7b093 commit c6d3b50
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion flood_adapt/integrator/sfincs_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,29 @@ def add_floodwall(self, floodwall: FloodWallModel, measure_path=Path):

# Add floodwall attributes to geodataframe
gdf_floodwall["name"] = floodwall.name
gdf_floodwall["z"] = floodwall.elevation.convert(UnitTypesLength("meters"))
if (gdf_floodwall.geometry.type == "MultiLineString").any():
gdf_floodwall = gdf_floodwall.explode()
# TODO: Choice of height data from file or uniform height and column name with height data should be adjustable in the GUI
try:
heights = [
float(
UnitfulLength(
value=float(height),
units=self.site.attrs.gui.default_length_units,
).convert(UnitTypesLength("meters"))
)
for height in gdf_floodwall["z"]
]
gdf_floodwall["z"] = heights
logging.info("Using floodwall height from shape file.")
except Exception:
logging.warning(
f"""Could not use height data from file due to missing ""z""-column or missing values therein.\n
Using uniform height of {floodwall.elevation.convert(UnitTypesLength("meters"))} meters instead."""
)
gdf_floodwall["z"] = floodwall.elevation.convert(UnitTypesLength("meters"))

# par1 is the overflow coefficient for weirs
gdf_floodwall["par1"] = 0.6

# HydroMT function: create floodwall
Expand Down

0 comments on commit c6d3b50

Please sign in to comment.