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

Hello. I need to create a PostGIS query that outputs roundabouts from OSM that have no "junction"="roundabout" tag. Is there a function that returns true if a geometry has a circular shape? I have tried ST_HasArc but it doesn't seem to be working. Any other suggestion on how to find roundabouts with missing "junction"="roundabout" tag is welcomed.

asked 16 Aug '16, 11:58

manuela_butuc's gravatar image

manuela_butuc
156259
accept rate: 100%

edited 16 Aug '16, 13:33

You could try to search for ways that have a highway tag and the same first and last node. Won't work for roundabouts that consist of multiple ways though.

(16 Aug '16, 14:29) scai ♦

Yes, i did that already, using ST_IsClosed function, but it's still not enough. I need something that goes more into detail

(16 Aug '16, 15:11) manuela_butuc

I suspect that this is very hard: there will be far too many edge cases to manage (for instance roundabout entrances & exits mapped to the same node; non-round roundabouts etc.)

(16 Aug '16, 19:01) SK53 ♦

After 2 days of trials, I think I have found a way around this problem. This is what I did:

  • selected only navigable roads (highways without pedestrian, footway, etc)

  • used the ST_IsClosed function to find only closed ways

  • selected only those ways that have between 7 and 40 nodes

  • selected only ways that have less than 500 m in length (could have gone lower, probably)

  • I created a centroid for each of the remaining ways with ST_Centroid function

  • I calculated the distance between each centroid and the nodes on the corresponding way

  • I calculated the standard deviation for the distances (centroid->nodes) and got numbers between 0.0001 and 0.267

  • I chose only the ways that have a standard deviation of maximum 0.08 (this is just a number I came up with after surveying the results)

I don't have a clean script to post right now, as I used many intermediate tables, but I plan to make one and post it on Github if anyone else is interested in finding roundabouts :) If you have suggestion of any other filters I could use to make the output even more accurate, i'm happy to read them!

permanent link

answered 17 Aug '16, 13:18

manuela_butuc's gravatar image

manuela_butuc
156259
accept rate: 100%

edited 17 Aug '16, 13:21

I will also calculate the distance between nodes of the way to see if they are similar, because the standard deviation for the distance between centroid&nodes is not enough to find roundabouts, it outputs ways like this one: https://postimg.org/image/l9ncwfo2x/

(17 Aug '16, 14:26) manuela_butuc
5

Impressed with the ingenuity!

I wonder if http://postgis.net/docs/ST_MinimumBoundingCircle.html might be useful as well.

(17 Aug '16, 17:24) Richard ♦
2

Years ago, I played with ST_Azimuth to find the maximum angle between three points. Underlying assumption was that roundabouts shouldn't have e.g. 90 degree angles in there. The idea is to choose some cut off maximum angle when querying data. Code is here: http://pastebin.com/nvZ3YrEF

(17 Aug '16, 18:53) mmd
1

@manuela_butuc I've accepted this as an answer on your behalf (since you can't accept your own answers). Hope this is OK...

(17 Aug '16, 19:26) SomeoneElse ♦
2

@Richard ♦ I read what that function does but I don't think it can help me with the roundabouts. Anyways, good to know it exists!

@mmd Thanks for the code snippet, it actually helped a lot!

(18 Aug '16, 08:59) manuela_butuc
1

Great piece of work. Would love to see it written up in a bit more detail (specifically with images of what gets selected & what gets rejected).

(18 Aug '16, 10:17) SK53 ♦

Wouldn't it make more sense to just treat it as a polygon and then calculate perimeter/sqrt(area) ratio? If it's close to minimal theoretical value (and has >=6 nodes), then you probably have a circle.

Consider also, that roundabouts may get divided into multiple ways for route relations.

(23 Aug '16, 00:29) RicoElectrico
showing 5 of 7 show 2 more comments
permanent link

answered 11 Apr '17, 18:07

manuelab_telenav's gravatar image

manuelab_tel...
3111
accept rate: 0%

Many of us, vector map-makers, do this roundabout recognition, and we do it from the times even before the OSM has been born. There are at least two basic reasons to that:

  • to provide more complete and safer turn-by-turn navigation network; and
  • when creating the vector scale levels, roundabouts quickly transform to ordinary nodes.

In addition to the answer and comments already provided I would rather add some hints/suggestions based on experience running data-preparation on OSM dumps though the numbers are some months old (I do not register them for every run/OSM dump).

The preparation-tool runs separately on any of the road classes (motorway, trunk, primary, secondary, tertiary, living-street and street) and detects way classes RAC (ways tagged as roundabout) and ORC (the rest or the ordinary roads, not tagged as roundabouts).

Within RAC, we create the roundabout (RA) class (single circular ways or end-to-end connected ways creating circular ways). Now, for the RA class we detect some 5-7 (average/statistical) parameters like the number of edges, the length of the edge, the convexity, the diameter and so on. Finally, within the RAC we detect:

  • The safe roundabout (SRA) class (253480 objects for all road classes). These are elements of RA having parameters close to the average values;
  • The unsafe roundabout (URA) class (6875), those from RA having at least one parameter far from the average value (outside the tolerance). This unsafe class of RA contains roundabouts wit anomalies as well (with self-crossings, more than one round between the start and end nodes, isolated, having more than one section between two nodes, zig-zag consecutive edges and so on);
  • The geo-rec based (GRA) class (708). This are created from the incomplete roundabouts where adding one or two short poly-line sections we create a safe roundabout; finally
  • The erroneous objects in RAC (2195). These are ways recognized as ordinary/feeding roads obviously tagged as roundabouts by mistake. This road segments are missing sections in ORC and therefor they are added to the ORC before further processing.
    -Within the ORC we detect circular single ways that closely (perfectly) match the corresponding safe SRA parameters. There were totally 101803 such cases, let us say, ordinary road roundabouts (ORRA).
    -Finally, in a similar way as for GRA we detect some 19547 geo-rec based roundabouts (GORRA) from the ORC class (with high probability also roundabouts).

Within any of the mentioned road types, we merge the described five roundabout classes to a final set of roundabouts. These are the input to further preparation, data generalisation, rooting …

Note that the last two roundabout sets (ORRA and GORRA) contain large number of turning-circles. Visual inspection on a large sample shows that mappers are having dilemma how to tag/upload these kinds of objects. At the same time qualifying turning-circles as roundabouts should not confuse robust line-following/rooting systems.

If interested, some more details can be found from my earlier OSM-dev and OSM-rooting forum discussions/posts here https://drive.google.com/open?id=0B6qGm3k2qWHqRVVXVVFwbVdtN1E

permanent link

answered 22 Aug '16, 20:27

sanser's gravatar image

sanser
695383955
accept rate: 5%

edited 23 Aug '16, 08:31

SK53's gravatar image

SK53 ♦
28.1k48268433

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:

×165
×134
×36

question asked: 16 Aug '16, 11:58

question was seen: 4,122 times

last updated: 11 Apr '17, 18:07

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