Study Vault Search notes, aliases and full text
Graph
ConceptADISAI-written · not yet proofread

Spatial Join

A spatial join combines two sets of objects by a spatial condition on their geometries, e.g. distance at most d, instead of equality of values; in SPARQL on OpenStreetMap it is written with WKT geometries and `geof:distance` in a FILTER.

Properties#

  • In SPARQL (GeoSPARQL, OpenStreetMap):
    • an object’s geometry is reached via geo:hasGeometry/geo:asWKT, a Property Path, and is a literal in WKT format (geo:wktLiteral), e.g. "POINT(7.842 47.998)"^^geo:wktLiteral;
    • the condition is a FILTER with geof:distance(g1, g2, unit), with the unit given as an IRI (unit:M for metres).
  • Constant side. In the lecture example, one side is a single fixed point, so the “join” selects all buildings within 500 m of that point. With a variable on both sides, the same FILTER joins two sets of objects, like the DBIS SQL example bus_stops JOIN restaurants ON ST_Distance(…) < 500 (DBIS_VL05 > Join operation).
  • ?building osmkey:building ?anything matches every OSM object with a building tag, whatever its value. The variable ?anything is only a placeholder.

Example#

PREFIX osmkey: <https://www.openstreetmap.org/wiki/Key:>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX unit: <http://qudt.org/vocab/unit/>
SELECT ?building ?building_wkt WHERE {
  ?building osmkey:building ?anything .
  ?building geo:hasGeometry/geo:asWKT ?building_wkt .
  FILTER (geof:distance("POINT(7.842 47.998)"^^geo:wktLiteral,
                        ?building_wkt, unit:M) <= 500)
}
# Buildings in a 500 m radius around Freiburg Hauptbahnhof

With toy geometries: building b1b_1 at 200 m and b2b_2 at 800 m from the point give the result {b1}\{b_1\}. The FILTER removes b2b_2.

Sources#

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only