Mechanical Edits/AutoMatt/Connecting NHD Waterways in Oklahoma 2
Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.
Who
I, Matt_ using an account for mechanical edits AutoMatt_, Overpass turbo and JOSM.
Contact
Please contact my main account via OSM.
What
In the state of Oklahoma:
- Find ways with NHD:FType=ArtificialPath, NHD:FType=Connector, or NHD:FType=StreamRiver
- For each of: the first node in the way, the last node in the way
- If the node is not shared by another waterway or water-body but there is a node belonging to another waterway or water-body (within 8 centimeters), then merge the nodes
- For each of: the first node in the way, the last node in the way
- If a way is an instance of NHD:FType=ArtificialPath and:
- It's inside a body of water tagged with natural=water or landuse=reservoir
- And nothing is connecting to its first node
- And there is no waterway existing in OSM or the NHD to connect to its first node
- And the way doesn't have a name=*
- And one of:
- The last node of the way is not connected to anything
- The last node of the way is connected to another waterway, but that node is also shared by the edge of the water-body
- The last node of the way is connected to another waterway and the water-body has a node within 8 cm the other way can be connected to instead
- Then: delete the way (and merge the first node of the other, formerly-connected, waterway with a node belonging to the water-body if needed)
If committed to the OpenStreetMap database, the end result will be:
- 17,429 ways modified due to having one of their nodes replaced due to a merge.
- 5,226 ways deleted due to being inside of bodies of water and not being needed to connect to anything
- 20,159 node merges involving 2-3 nodes each (all but 10 are of only 2 nodes). 28,394 nodes to delete. 100% of deleted nodes have no tags at all.
Why
NHD water features were imported over a decade ago in Oklahoma and have the common issue of waterways ending in nodes on top of each other without actually connecting. This change is to fix this widespread issue by merging nodes where doing so is safe (the nodes don't have tags of their own, are nearly at the same coordinates, and don't belong to ways or ways-belonging-to-relations tagged with anything delicate like boundary=administrative or natural=coastline.)
How
The following Overpass turbo query was used (result size: >600 MB):
[out:json][timeout:1800][bbox:33.616646,-103.004057,37.0022,-94.432823]; (way["NHD:FType"="ArtificialPath"];way["NHD:FType"="Connector"];way["NHD:FType"="StreamRiver"];); node(w)->.set; node(around.set:0.05); (way(bn);rel(bw);); (._;>;); out body;
Then, I wrote a program to parse the information according the logic in the #What section, above.
The changes are made in JOSM, after downloading the data from Overpass, by running a script (example: pipe_tape_sample2.js)
A zipped osm file containing all of the proposed changes (19.1MB zipped, 141 MB uncompressed): ok_after.zip
Discussion
Repetition
None, this is one-and-done.
Results
- 147299041 (achavi, OSMLab)
- 147331904 (achavi, OSMLab)
- 147342875 (achavi, OSMLab)
- 147344816 (achavi, OSMLab)
- 147348298 (achavi, OSMLab)
- 147349326 (achavi, OSMLab)
- 147350330 (achavi, OSMLab)
Status: Done.