NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am working on importing a number of ways obtained as a result of vectorizing of a raster map. Because of the nature of the source data and as a result of chosen curve smoothing algorithm there are many cases when a single way intersects itself. In general, self-intersection has no automatic resolution in e.g. JOSM and requires human intervention, which in my case would be many hundreds of edits.

However, in my case it is always a very specific type of self-intersection that should rather be described as a "self-touching way". Let me illustrate it.

intersection

On the image above pay attention that there is a node an the intersection point, at direction of individual segments make it so that the right part of the "eight"-like figure touches the left part of it in that point. So it is not two duplicate notes (different IDs but same coordinates) but rather a single node (the same ID) that is present two times in a same way. Inspecting the OSM XML confirms this observation.

An algorithmic solution that is possible in this case is to remove one occurrence of that repeating node from the way. The result of such transformation for my example is below:

split

This transformation reaches the goal of preserving a "waistline" in the eight-shaped polygon, only making it slightly "thicker". This is an acceptable approximation given the resolution of the original raster data and noise already present in it.

The same effect can be achieved manually: a) duplicate the node, b) delete one of the copied nodes.

Such a solution is fine for my application and is guaranteed to create no new self-intersections because of the way the polygon is oriented (orientation of the top circle and the bottom circle always match).

I can come up with a solution that involves scripted editing of the underlying OSM-XML (see my own answer below). But I wonder if there are solutions to do it automatically without the need to export to OSM format, e.g. directly in the JOSM editor.

P.S. An alternative solution is to create two independent ways touching each other at the central node (upper circle and a lower circle). It is a bit harder to do when editing an XML in a sense that new ways have to be allocated, but is also acceptable for me if there are ready tools to do that.

asked 04 Apr '19, 09:40

Atakua's gravatar image

Atakua
11123
accept rate: 0%


My own solution so far is to export the JOSM layer into an OSM XML file. Then to use a scripted language capable of processing XML (Python or any other really) to open the file and do the following.

  • For each way check if there are repeating node IDs ("ref" tag) included into it.
  • If there are such repetitions, keep only one of them
  • Make an exception for the first and the last node reference in the way. For closed ways their IDs are the same.

As I mentioned already, applying such script requires exporting data from JOSM, processing it and then reopening it in JOSM for further processing and uploading to the database.

permanent link

answered 04 Apr '19, 09:46

Atakua's gravatar image

Atakua
11123
accept rate: 0%

1

Has your import actually gone through this process https://wiki.openstreetmap.org/wiki/Import/Guidelines ?

(04 Apr '19, 10:50) SimonPoole ♦

@SimonPoole Steps 1 to 3 of that processes are done, now at step 4 "Documentation". Tracked by me and others here: https://wiki.openstreetmap.org/wiki/WikiProject_Sweden/naturvardsverket_import . Resolution of technical issues to understand if it is at all doable, which this question is actually about, is being done in parallel.

(04 Apr '19, 11:16) Atakua

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×622
×2

question asked: 04 Apr '19, 09:40

question was seen: 2,005 times

last updated: 04 Apr '19, 11:16

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum