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
[21pt] PR: Adding Open Street Map bridge data pulling and healing scripts #1122
Conversation
This is potentially user error but I've run into the following error. I'm wondering if I used the wrong input for the I ran this command:
and received this error:
|
Per @EmilyDeardorff 's finding, I'll modify the requirements to specify that the WBD / HUC8 shapefiles must contain the field "HUC8" |
I ran into the following error when testing the optional
|
I also ran into the following error with the
|
@EmilyDeardorff it looks like I have some old versions of packages like shapely that use those data, and when I updated them, I get those errors now. They're being treated as strings instead of numeric values, so they'll just need a typecast. I'll push that update in just a second. |
Can I get some information to what is needed to plug this in. It sounds like I need to full CONUS scale pull for the new input files. Then how does the next part work? Do we need to run it against all HUCs as part of pre-clip? or is it part of the run_unit_wb.sh or part of the post processing? |
This PR introduces two new scripts to be run individually, in order. The first script to be run is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions/Notes:
- I would suggest updating the sample usage text to have the updated path (
python3 foss_fim/src/heal_bridges_osm.py
) rather than the current text (python3 /data/bridges/heal_bridges_osm.py
) - The most recent docker image (
dev_20240416_adb6e36
) does not have the necessaryosmnx
package, but that issue will be resolved after the merge. I got around this during testing by usingpip install osmnx
within the docker container.
Testing Results:
Tested data/bridges/pull_osm_bridges.py
and src/heal_bridges_osm.py
. on the Texas HUCs wbd (on Dev1 at /home/laura.keys/wbd/tx_hucs.shp
).
I tested the following commands, both of which ran as expected:
python3 /foss_fim/data/bridges/pull_osm_bridges.py -w /osm_bridges/tx_hucs/tx_hucs.shp -p /osm_bridges/test_outputs/ -l /osm_bridges/test_outputs/osm_bridges.shp -m /osm_bridges/test_outputs/osm_bridges_midpts.shp
→ ✅worked as expected
python3 foss_fim/src/heal_bridges_osm.py -g /data/outputs/dev-branch-outlet-backpools/ -s /osm_bridges/tx_hucs/tx_hucs.shp -b /osm_bridges/test_outputs/bridge_lines_folder/ -o /osm_bridges/test_outputs/ -u /osm_bridges/test_outputs/final_osm_hand/
→ ✅worked as expected
I also tested the following three optional commands for the heal_bridges_osm.py
script:
-r --resolution
→ ✅worked as expected after adjustment-w --buffer_width
→ ✅worked as expected after adjustment-i --hucs_of_interest
→ ✅worked as expected
I looked over the output results and from these scripts and they looked like I was expecting. I did not run FIM pipeline on the results.
I updated the sample usage text per @EmilyDeardorff 's suggestion (since the example path I had listed wasn't accurate in the least) and also added in a note where we would incorporate lidar into HAND grids in the future |
We have a new python package which needs to be added and a new Pipfile and Pipfile.lock checked in with this branch. For details on how to do this see FIM4 - Updating Python Packages for Docker. I can help guide if you like. |
Thinking about this a little more... It may be more efficient to change the code up a bit to optionally accept a layer name as an argument. If a layer name is specified, then the code will know to just load that specific layer from the geopackage. This way, we don't have to keep around 2 copies of the exact same dataset. The WBD gpkg is quite a large vector dataset. |
I was playing with the script. It is all built based on shape files and was finicky, so I changed it over to using only gkpg, which is also easier to deploy. So, I made a copy of the WBD_National.HUC8 layer, stripped out all of the HUCs in the HUC2 area of 22. I set it's default projection to 4269 as the OSM api seems to like that better. I am still testing it and making some tweaks but it is going well. When the script creates the final gkpg output, I make sure it is in 5070. |
I really want to avoid having to keep the same dataset around in a separate gpkg just to have it in a different projection. Can we use our default input WBD gpkg and reproject to 4269 after we load it in? |
Yes. I had trouble getting it load correctly against OSM, but have that worked out now. We can now use the full WBD_National.gpkg. |
Continued to have trouble with WBD_National.gpkg which I think is because it's ESRI:102039, but I when I switch to another WBD that we have in use, WBD_National_EPSG_5070.gpkg. The problem is that the OSM api seems to only like EPSG:4326 going in. When I tried to reproject from ESRI:102039, memory couldn't seem to handle it. In all other places in our tools, all are masked first. This was the first time in FIM that anyone loaded the full WBD_National asking for the HUC8 layer, then re-projecting it. Strange. All is well now using WBD_National_EPSG_5070.gpkg. It still has all HUC layers (2, 4, 6, 8) but not sure why we don't have just a WBD_National with HUC8 only. Even WBD_National_EPSG_5070.gpkg has all 4 layers. Oh well. I also added multi-proc, a ton of more outputs, error trapping, fixed some errors, etc. I am going to retry a full scale now and see how we do. |
…ion-mapping into dev-osm-bridges
…ion-mapping into dev-osm-bridges
This PR includes 2 scripts to add Open Street Map bridge data into the HAND process: a script that pulls data from OSM and a script that heals those bridges in the HAND grids. Both scripts should be run as part of a pre-processing step for FIM runs. They only need to be run if we think OSM data has changed a lot or for any new FIM versions.
A new docker image is also required for
pull_osm_bridges.py
(acquire and preprocess) script.Additions
data/bridges/pull_osm_bridges.py
: First pre-processing script that pulls OSM data and saves bridge lines out as separate shapefiles by HUC8 to a specified locationsrc/heal_bridges_osm.py
: Second pre-processing script that uses the pre-saved OSM bridge lines and heals max HAND values across those bridge lines. Healed HAND grids are saved to a specified location.Changes
Pipfile
,Pipfile.lock
: Adjusted files to add new python package to docker image.data
clip_vectors_to_wdbd.py
: Updated to pre-clip new bridge data. Logging upgraded.generate_pre_clip_fim_huc8.py
: Updated to pre-clip new bridge data. Logging added and a system for multi-process logging.src
delineate_hydros_and_produce_HAND.sh
: add python call to runheal_bridges_osm.py
after hydraulic properties are calculated.bash_variables.env
: Added new variable for OSM bridges and adjusted pre-clip output dateutils
shared_functions.py
: removed function no longer in use.shared_variables.py
: removed variables no longer in use.Deployment Plan
pull_osm_bridges.py
to get all new raw OSM bridge data. Now completed. Saved the file as inputs/osm/bridges/240426/osm_all_bridges.gpkg.osm_all_bridges.gpkg
to all 6 enviros.generate_pre_clip_fim_huc8.py
to get a full new CONUS and Alaska set of pre-clip files. This is now done using folder name of240502
, however another PR is coming soon requiring all Alaska HUCs to be re-run. After the new Alaska pre-clips are run, it can be merged into240502
.Testing
pull_osm_bridges.py
:heal_bridges_osm.py
:Issuer Checklist (For developer use)
You may update this checklist before and/or after creating the PR. If you're unsure about any of them, please ask, we're here to help! These items are what we are going to look for before merging your code.
[_pt] PR: <description>
dev
branch (the default branch), you have a descriptive Feature Branch name using the format:dev-<description-of-change>
(e.g.dev-revise-levee-masking
)dev
branchpre-commit
hooks were run locally/foss_fim/
, run:pytest unit_tests/
)4.x.x.x
Merge Checklist (For Technical Lead use only)