Mechanical Edits/AutoMatt/Connecting NHD Waterways in Oklahoma
Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.
Who
I, Matt_ using a newly created 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 and NHD:FType=Connector that have no waterway=* or natural=* tags and tag them with waterway=stream
- All of these ways are connected to (or will be connected to) other streams. Some touch existing rivers but are not part of the river, only flowing into it. ArtificialPaths that are part of rivers appear to have already been fixed by others.
- Merge nodes at the ends of these ways when doing so would connect them to other valid waterways with ends at the same coordinates (within 5 centimeters)
- If another object, including but not limited to natural=water, also has a node at the same coordinates, it will be included in the merge.
- If the ArtificialPath is already connected to all other waterways ending at the same position, no node merge will occur, even if there are other objects with nodes at the same coordinates.
- Nothing part of a boundary=administrative is touched by this, I've already handled the few that existed manually without moving any borders.
If committed to the OpenStreetMap database, the end result will be:
- 19,567 ways modified due to waterway=stream being added to them. 33,678 ways modified in total due to having one of their nodes replaced due to a merge.
- 15,068 node merges involving 2-5 nodes each (about 70% of merges are of 3 nodes and 30% are of only 2 nodes). 26,196 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.
For example, 138067071 138067071 (version #1 as of this writing) is only tagged as an ArtificialPath and does not connect to the streams north and south of it.
My proposal is to tag it as waterway=stream and connect it to the streams its ends are on top of by merging the necessary nodes.
How
The following Overpass turbo query was used (result size: 233 MB):
[out:json][timeout:1800][bbox:33.616646,-103.004057,37.0022,-94.432823]; (way["NHD:FType"="ArtificialPath"];way["NHD:FType"="Connector"];); node(w)->.set; node(around.set:0.05); (way(bn);rel(bw);); (._;>;); out body;
Then, I wrote a program to parse the information, and for each ArtificialPath, it only looks at its first and last node. For each of those, it takes the nodes within 0.05 meters and their parent ways and relations. For those nodes, it makes a decision on whether they should be merged. It merges the nodes if doing so would cause the ArtificialPath to become connected to one of: another ArtificalPath, Connector, or one of these waterways: stream/river/canal/ditch/drain. Otherwise no node merging happens.
The changes are made in JOSM, after downloading the data from Overpass, by running a script (example: pipe_tape_sample.js)
A zipped osm file containing all of the proposed changes (12.2MB zipped, 176 MB uncompressed): oklah_after_smaller.zip
Discussion
Repetition
None, this is one-and-done.
Results
- Between -100.1 and -98.5 degrees West longitude
- Between -98.5 and -97.1 degrees West longitude
- Between -97.1 and -96.75 degrees West longitude
- Between -96.75 and -96.4 degrees West longitude
- Between -96.4 and -96.1 degrees West longitude
- Between -96.1 and -95.0 degrees West longitude
Status: Done.