Skip to content

Commit

Permalink
v4.5.13.2 Fixed osmid and added huc column (#1360)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZahraGhahremani authored Jan 3, 2025
1 parent 1fa128f commit 7c819df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion data/bridges/pull_osm_bridges.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def pull_osm_features_by_huc(huc_bridge_file, huc_num, huc_geom):
gdf['railway'] = None

# Create the bridge_type column by combining above information
gdf['HUC'] = huc_num
gdf['bridge_type'] = gdf.apply(
lambda row: (
f"highway-{row['highway']}" if pd.notna(row['highway']) else f"railway-{row['railway']}"
Expand Down Expand Up @@ -187,7 +188,7 @@ def combine_huc_features(output_dir):
section_time = dt.datetime.now(dt.timezone.utc)
logging.info(f" .. started: {section_time.strftime('%m/%d/%Y %H:%M:%S')}")

all_bridges_gdf = all_bridges_gdf_raw[['osmid', 'name', 'bridge_type', 'geometry']]
all_bridges_gdf = all_bridges_gdf_raw[['osmid', 'name', 'bridge_type', 'HUC', 'geometry']]
all_bridges_gdf.to_file(osm_bridge_file, driver="GPKG")

return
Expand Down
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.13.2 - 2025-01-03 - [PR#1360](https://github.com/NOAA-OWP/inundation-mapping/pull/1360)

Fixed missing osmid in osm_bridge_centroid.gpkg. Also, HUC column is added to outputs.

### Changes
- `data/bridges/pull_osm_bridges.py`
- `src/aggregate_by_huc.py`

<br/><br/>


## v4.5.13.1 - 2024-12-13 - [PR#1361](https://github.com/NOAA-OWP/inundation-mapping/pull/1361)

This PR was triggered by two dep-bot PR's. One for Tornado, one for aiohttp. Upon further research, these two exist only as dependencies for Jupyter and Jupyterlab which were very out of date. Upgrading Jupyter/JupyterLab took care of the other two.
Expand Down
3 changes: 2 additions & 1 deletion src/aggregate_by_huc.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def aggregate_bridge_pnts(self, branch_path, branch_id):
if not os.path.isfile(bridge_filename):
return

bridge_pnts = gpd.read_file(bridge_filename)
bridge_pnts = gpd.read_file(bridge_filename, dtype=self.bridge_dtypes)
if bridge_pnts.empty:
return
hydrotable_filename = join(branch_path, f'hydroTable_{branch_id}.csv')
Expand Down Expand Up @@ -288,6 +288,7 @@ def agg_function(
(c > 1) & (bridge_pnts.feature_id != bridge_pnts.crossing_feature_id), 'is_backwater'
] = 1
# Write file
bridge_pnts = bridge_pnts.astype(self.bridge_dtypes, errors='ignore')
bridge_pnts.to_file(bridge_pnts_file, index=False, engine='fiona')

# print(f"agg_by_huc for huc id {huc_id} is done")
Expand Down

0 comments on commit 7c819df

Please sign in to comment.