Skip to content

Commit

Permalink
v4.5.5.1 Fix heal_bridges_osm.py warning (#1225)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZahraGhahremani authored Aug 16, 2024
1 parent c20e897 commit b282955
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
11 changes: 11 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,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.5.5.1 - 2024-08-16 - [PR#1225](https://github.com/NOAA-OWP/inundation-mapping/pull/1225)

Removes warning when running `heal_bridges_osm.py` by not saving the empty DataFrame.

### Changes

- `src/heal_bridges_osm.py`

<br/><br/>


## v4.5.5.0 - 2024-08-16 - [PR#1247](https://github.com/NOAA-OWP/inundation-mapping/pull/1247)

Updated the gauge crosswalk and SRC adjustment routine to use the ras2fim v2 files. The v2 ras2fim file structure was changed to organize the data by huc8 - one gpkg and csv per huc8. Addresses #1091
Expand Down
12 changes: 8 additions & 4 deletions src/heal_bridges_osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def process_bridges_in_huc(

# Get max hand values for each bridge
osm_gdf['max_hand'] = zonal_stats(
osm_gdf['geometry'], hand_grid_array, affine=hand_grid.transform, stats="max"
osm_gdf['geometry'], hand_grid_array, affine=hand_grid.transform, stats="max", nodata=-999
)
# pull the values out of the geopandas columns so we can use them as floats
osm_gdf['max_hand'] = [x.get('max') for x in osm_gdf.max_hand]
Expand Down Expand Up @@ -71,9 +71,12 @@ def process_bridges_in_huc(
osm_gdf['branch'] = branch_id
osm_gdf['mainstem'] = 0 if branch_id == '0' else 1

# Write the bridge points to a geopackage
osm_gdf.to_file(bridge_centroids, index=False)

# Check if the GeoDataFrame is empty
if not osm_gdf.empty:
# Write the bridge points to a geopackage
osm_gdf.to_file(bridge_centroids, index=False)
else:
print('The geoDataFrame is empty.File not saved.')
return


Expand All @@ -100,6 +103,7 @@ def flows_from_hydrotable(bridge_pnts, hydroTable):
python3 src/heal_bridges_osm.py
-g /outputs/fim_4_4_15_0/1209301/branches/3763000013/rem_zeroed_masked_3763000013.tif
-s /outputs/fim_4_4_15_0/1209301/osm_bridges_subset.gpkg
-p /outputs/fim_4_4_15_0/1209301/branches/3763000013/gw_catchments_reaches_filtered_addedAttributes_crosswalked_3763000013.gpkg
-c /outputs/fim_4_4_15_0/1209301/1209301/branches/3763000013/osm_bridge_centroids_3763000013.tif
-b 10
-r 10
Expand Down

0 comments on commit b282955

Please sign in to comment.