From d3987572a8b0607a91215dba7df5e5ac3fbf663a Mon Sep 17 00:00:00 2001 From: MattLuck-NOAA Date: Wed, 23 Jul 2025 13:25:06 -0600 Subject: [PATCH 1/6] use fiona to gpd.read_file() --- src/mask_dem.py | 11 ++++------- src/mitigate_branch_outlet_backpool.py | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/mask_dem.py b/src/mask_dem.py index 7f92ffc7a..0b55ea7ab 100755 --- a/src/mask_dem.py +++ b/src/mask_dem.py @@ -11,7 +11,7 @@ from rasterio.mask import mask -gpd.options.io_engine = "pyogrio" +# gpd.options.io_engine = "pyogrio" def mask_dem( @@ -71,7 +71,9 @@ def mask_dem( elif os.path.exists(levee_levelpaths): # Mask levee-protected areas protected against level path - levee_levelpaths = pd.read_csv(levee_levelpaths) + catchments = gpd.read_file(catchments_filename, engine='fiona') + levee_levelpaths = pd.read_csv(levee_levelpaths, engine='fiona') + leveed = gpd.read_file(nld_filename, engine='fiona') # Select levees associated with branch levee_levelpaths = levee_levelpaths[levee_levelpaths[branch_id_attribute] == branch_id] @@ -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'] @@ -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 diff --git a/src/mitigate_branch_outlet_backpool.py b/src/mitigate_branch_outlet_backpool.py index 607fc57ab..e99014f10 100755 --- a/src/mitigate_branch_outlet_backpool.py +++ b/src/mitigate_branch_outlet_backpool.py @@ -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: @@ -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'] @@ -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 From a12adbda8ac3d0574949cbdc11a656a5fa2bd230 Mon Sep 17 00:00:00 2001 From: MattLuck-NOAA Date: Wed, 23 Jul 2025 13:36:35 -0600 Subject: [PATCH 2/6] update changelog --- docs/CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index c89907b30..9d9748e32 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project will be documented in this file. We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. +## 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()`. 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`. + +

+ ## 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. From 524baa7b3dedab94c404833334e1c0c68f2282af Mon Sep 17 00:00:00 2001 From: MattLuck-NOAA Date: Wed, 23 Jul 2025 13:42:23 -0600 Subject: [PATCH 3/6] update changelog --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9d9748e32..38157c40b 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -4,7 +4,7 @@ We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. ## 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()`. The issue was originally documented in #1376 and fixed in #1490, but two more files are fixed here. +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 From c84e0239bef03c2fcd1d8a7b0154d4ad6852d90a Mon Sep 17 00:00:00 2001 From: MattLuck-NOAA Date: Thu, 24 Jul 2025 08:03:08 -0600 Subject: [PATCH 4/6] Update mask_dem.py --- src/mask_dem.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mask_dem.py b/src/mask_dem.py index 0b55ea7ab..c1ea77ece 100755 --- a/src/mask_dem.py +++ b/src/mask_dem.py @@ -72,7 +72,7 @@ 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, engine='fiona') + levee_levelpaths = pd.read_csv(levee_levelpaths) leveed = gpd.read_file(nld_filename, engine='fiona') # Select levees associated with branch From 5b040c9a0052f2fc1682445083221e7d7412db29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CRobHanna-NOAA=E2=80=9D?= <“Robert.Hanna@NOAA.gov”> Date: Fri, 19 Sep 2025 17:32:19 +0000 Subject: [PATCH 5/6] merge dev and changelog.md --- docs/CHANGELOG.md | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 67142eec6..67a282c7a 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,16 @@ All notable changes to this project will be documented in this file. We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. +## v4.8.10.7 - 2025-09-19 - [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`. +
+ ## v4.8.10.6 - 2025-09-19 - [PR#1642](https://github.com/NOAA-OWP/inundation-mapping/pull/1642) Adjust eval_plot.py so it only looks for the config file when in -sp (spatial) mode. Spatial mode is used when running the tool to create FIM_performance files. In that mode, it can only run in OWP servers as it needs to talk to internal servers. @@ -279,19 +289,7 @@ Addresses bug related to the `location_id` data type that is read in from the `a ### Changes `src/src_adjust_usgs_rating_trace.py`: Added `dtype={'location_id': object}` to the acceptable_sites csv file read - -

- - -## 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`. - +

## v4.8.7.1 - 2025-07-18 - [PR#1539]([https://github.com/NOAA-OWP/inundation-mapping/pull/1539]) From 5f48eaa6287ba74c1ae149f874326be8f9f09437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CRobHanna-NOAA=E2=80=9D?= <“Robert.Hanna@NOAA.gov”> Date: Fri, 19 Sep 2025 17:33:58 +0000 Subject: [PATCH 6/6] update changelog --- docs/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 67a282c7a..d8c279328 100755 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,7 +1,7 @@ All notable changes to this project will be documented in this file. We follow the [Semantic Versioning 2.0.0](http://semver.org/) format. -## v4.8.10.7 - 2025-09-19 - [PR#1608]([https://github.com/NOAA-OWP/inundation-mapping/pull/1608]) +## v4.8.10.7 - 2025-09-19 - [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.