Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ Addresses bug related to the `location_id` data type that is read in from the `a
<br/><br/>


## v4.x.x.x - 2025-07-23 - [PR#1608]([https://github.com/NOAA-OWP/inundation-mapping/pull/1608])

Changes files to use `fiona` as the I/O engine when reading files with `gpd.read_file()` to avoid segmentation faults. The issue was originally documented in #1376 and fixed in #1490, but two more files are fixed here.

### Changes

- `src/`
- `mask_dem.py` and `mitigate_branch_outlet_backpool.py`: Added `engine='fiona'` to `gpd.read_file()`. Also removed an unnecessary file read in `mask_dem.py`.

<br/><br/>

## v4.8.7.1 - 2025-07-18 - [PR#1539]([https://github.com/NOAA-OWP/inundation-mapping/pull/1539])

Updates the CatFIM site comparison tool to make the outputs better suited to be loaded into HydroVis. Add % change calculations to site change outputs.
Expand Down
9 changes: 3 additions & 6 deletions src/mask_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from rasterio.mask import mask


gpd.options.io_engine = "pyogrio"
# gpd.options.io_engine = "pyogrio"


def mask_dem(
Expand Down Expand Up @@ -71,7 +71,9 @@ def mask_dem(

elif os.path.exists(levee_levelpaths):
# Mask levee-protected areas protected against level path
catchments = gpd.read_file(catchments_filename, engine='fiona')
levee_levelpaths = pd.read_csv(levee_levelpaths)
leveed = gpd.read_file(nld_filename, engine='fiona')

# Select levees associated with branch
levee_levelpaths = levee_levelpaths[levee_levelpaths[branch_id_attribute] == branch_id]
Expand All @@ -80,8 +82,6 @@ def mask_dem(
levelpath_levees = list(levee_levelpaths[levee_id_attribute])

if len(levelpath_levees) > 0:
leveed = gpd.read_file(nld_filename, engine='fiona')

# Get geometries of levee protected areas associated with levelpath
geoms = [
feature['geometry']
Expand All @@ -93,9 +93,6 @@ def mask_dem(
dem_masked, _ = mask(dem, geoms, invert=True)

# Mask levee-protected areas not protected against level path
catchments = gpd.read_file(catchments_filename, engine='fiona')
leveed = gpd.read_file(nld_filename, engine='fiona')

leveed_area_catchments = gpd.overlay(catchments, leveed, how="union")

# Select levee catchments not associated with level path
Expand Down
8 changes: 4 additions & 4 deletions src/mitigate_branch_outlet_backpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def mask_raster_to_boundary(raster_path, boundary_json, save_path):

# --------------------------------------------------------------
# Read in nwm lines, explode to ensure linestrings are the only geometry
nwm_streams = gpd.read_file(nwm_streams_filename).explode(index_parts=True)
nwm_streams = gpd.read_file(nwm_streams_filename, engine='fiona').explode(index_parts=True)

# Check whether it's branch zero
if 'levpa_id' in nwm_streams.columns:
Expand Down Expand Up @@ -294,8 +294,8 @@ def mask_raster_to_boundary(raster_path, boundary_json, save_path):
# print(f'No catchment pixels geome at {catchment_reaches_filename}.')

# Read in split_flows_file and split_points_filename
split_flows_geom = gpd.read_file(split_flows_filename)
split_points_geom = gpd.read_file(split_points_filename)
split_flows_geom = gpd.read_file(split_flows_filename, engine='fiona')
split_points_geom = gpd.read_file(split_points_filename, engine='fiona')

# Subset the split flows to get the last one
split_flows_last_geom = split_flows_geom[split_flows_geom['NextDownID'] == '-1']
Expand Down Expand Up @@ -423,7 +423,7 @@ def mask_raster_to_boundary(raster_path, boundary_json, save_path):
# print("gdal_polygonize executed successfully.") # verbose

# Read in the polygonized catchment pixels
cp_poly_geom = gpd.read_file(catchment_pixels_polygonized_filename)
cp_poly_geom = gpd.read_file(catchment_pixels_polygonized_filename, engine='fiona')

# --------------------------------------------------------------
# Mask problematic pixel catchment from the catchments rasters
Expand Down