Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5pt] PR: Fixed osmid and added huc column #1360

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
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.x.x - 2024-12-06 - [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.12.1 - 2024-11-22 - [PR#1328](https://github.com/NOAA-OWP/inundation-mapping/pull/1328)

Fixes bug and adds error checking in FIM Performance. Fixes #1326.
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
Loading