Mechanical Edits/AutoMatt/Connecting NHD Waterways in Oklahoma

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.


I, Matt_ using a newly created account for mechanical edits AutoMatt_, Overpass turbo and JOSM.


Please contact my main account via OSM.


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.


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, way 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.

Waterway map of Oklahoma before mechanical edit
Waterways in Oklahoma connect in small clusters but overall are separate from each other. The ways to complete these connections already exist and just need their end nodes merged.


The following Overpass turbo query was used (result size: 233 MB):

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):



None, this is one-and-done.


Status: Done.