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 |
After 2 days of trials, I think I have found a way around this problem. This is what I did:
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! answered 17 Aug '16, 13:18 manuela_butuc 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
|
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:
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:
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 |
Here's a PostGIS script doing just that: https://github.com/TelenavMapping/useful-postgis-queries/blob/master/sql-queries/detect_possible_roundabouts.sql Enjoy! answered 11 Apr '17, 18:07 manuelab_tel... |
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.
Yes, i did that already, using ST_IsClosed function, but it's still not enough. I need something that goes more into detail
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.)