Street intersections #1696
-
One of the more popular Overpass queries (based on people asking for it) is for street intersections in a given area. Overpass is able to do this in part because it can easily recurse from a way to its members and also has a Since there aren’t any triples explicitly tying ways to their constituent nodes (ad-freiburg/osm2rdf#72), we’d have to ignore connectedness, which may mishandle some double-decker roads and such. This is the closest I’ve come for street intersections in Chicago: PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX osmrel: <https://www.openstreetmap.org/relation/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX osm: <https://www.openstreetmap.org/>
PREFIX ogc: <http://www.opengis.net/rdf#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
SELECT ?intersection (COUNT(DISTINCT ?street) as ?count_street) (GROUP_CONCAT(DISTINCT ?name; SEPARATOR=" at ") as ?names) (SAMPLE(?geometry) as ?intersection_geometry) WHERE {
?street osmkey:highway ?classification .
?street rdf:type osm:way .
?street osmkey:name ?name .
osmrel:122604 ogc:sfIntersects ?intersection .
?street ogc:sfIntersects ?intersection .
?intersection rdf:type osm:node .
?intersection geo:hasGeometry/geo:asWKT ?geometry .
}
GROUP BY ?intersection
HAVING(COUNT(DISTINCT ?name) >= 2) Unfortunately, this still only returns nodes that have tags on them, which happen to be at the major intersections but not the minor intersections: I’ve also tried the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
@1ec5 Thanks for the great query!
|
Beta Was this translation helpful? Give feedback.
-
@1ec5 It now also works for the whole planet. For example, here are all intersections of (named) streets in Chicago: https://qlever.cs.uni-freiburg.de/osm-planet/bZHGhm . It even works for the whole US (takes a while though): https://qlever.cs.uni-freiburg.de/osm-planet/1DHcyB . |
Beta Was this translation helpful? Give feedback.
@1ec5 It now also works for the whole planet. For example, here are all intersections of (named) streets in Chicago: https://qlever.cs.uni-freiburg.de/osm-planet/bZHGhm . It even works for the whole US (takes a while though): https://qlever.cs.uni-freiburg.de/osm-planet/1DHcyB .