Paul’s Blog

A blog without a good name

Simplifying NHN Waterways

When the NHN waterways were imported in BC, they were over-digitized and had too many nodes in them for the accuracy they had. This was detrimental to editing since areas far away from the city which had not been mapped by hand had a node density equal to that of the city.

Lately I’ve been bulk simplifying these waterways, as well as fixing up incorrect tagging.

The first step is to download the area of interest. In my case, I use my local XAPI server to download an entire watershed at once, dealing with a 50 MB .osm file. Since I don’t have to scroll around when editing I just stay zoomed in with JOSM and allocate it extra memory.

To download the area that the Seymour watershed is in, I used the command curl -o seymour.osm 192.168.1.5:8080/xapi/api/0.6/\*\\\[bbox=-123.33252,49.25526,-122.84637,49.59291\\\].

It’s important to escape the square brackets, then escape the backslashes or either curl or the shell will try to interpret the URL.

After this downloads, I open it up in JOSM, and immediately turn on wireframe mode and zoom in. This keeps JOSM working at a tolerable speed.

I want to start by turning the “connector” waterways into normal waterways. The NHN includes ways under rivers and lakes tagged with sub_sea=stream. This may be a good idea in theory, but in practice most of these ways were under rivers you could throw a rock across and should of been tagged with waterway=stream or waterway=river.

To fix the tagging, I start by selecting and copying a NHN stream with no name. These are found all over, so I just pick any random one. I then select source=GeobaseNHN_Import_2009 sub_sea=*, remove all tags except name, then paste the tags of the stream I copied with shift-control-V.

Normally when I’m doing this, I’m operating on an area and do the simplification by bbox, not by watershed. In this case, I ended up working with a slightly different workflow since I wanted to do just the Seymour Watershed.

The NHN import came in with waterway:type, oneway and accuracy:meters tags. To handle these, I select source=GeobaseNHN_Import_2009 waterway=* and delete waterway:type and oneway, and rename accuracy:meters to accuracy.

This time, I selected the main river and formed one way out of it, but I wouldn’t normally do so.

I now upload, hoping for no conflicts. If I’m using an extract, this is where I could have problems, but one of the advantages of using my XAPI server is it’s up to date and I can pull large areas without overloading scarce resources.

I now search for source=GeobaseNHN_Import_2009 waterway=* with and use JOSM’s simplify way tool with the preference simplify-way.max-error=1.8.

Because the NHN streams have the property that they will only join a new stream at the end of a way and simplify ways will never remove an end node, this should not introduce conflicts in areas that are only partially downloaded. If I see a large river that has already been joined to one way leaving the bbox I downloaded, I exclude it from the selection.

I then upload. If the changeset is going to be more then 50,000 nodes removed, I start with a major river and work outwards.

To do this I select source=GeobaseNHN_Import_2009 waterway=stream (parent child selected) to select the streams that adjoin a river, and run this query a few times, then upload. I then run it a few more times and upload to a new changeset, and repeat until all ways are simplified.