Lably
Skip to content

GeoSPARQL

Geospatial extension for SPARQL

  • 6 min read
  • 6 chapters

Related on Lably

Through Topology

As of version 1.1, published in 2024, a validator for RDF data to meet GeoSPARQL patterns is also supplied, using SHACL as well as a Simple Features hierarchy of geometry classes and a vocabulary of GeoSPARQL rules and functions.

The definition of a small ontology based on well-understood OGC standards is intended to provide a standardized exchange basis for geospatial RDF data which can support both qualitative and quantitative spatial reasoning and querying with the SPARQL database query language.

The Ordnance Survey Linked Data Platform uses OWL mappings for GeoSPARQL equivalent properties in its vocabulary. The LinkedGeoData data set is a work of the Agile Knowledge Engineering and Semantic Web (AKSW) research group at the University of Leipzig, a group mostly known for DBpedia, that uses the GeoSPARQL vocabulary to represent OpenStreetMap data.

In particular, GeoSPARQL provides for:

  • a small topological ontology in RDFS/OWL for representing Features and Geometries
  • serializations of geometry position (coordinate) literals
  • Simple Features, RCC8, and DE-9IM (a.k.a. Clementini, Egenhofer) topological relationship vocabularies and ontologies for qualitative reasoning, and
  • a SPARQL query interface using
    • a set of topological SPARQL extension functions for quantitative reasoning, and
    • a set of Rule Interchange Format (RIF) Core inference rules for query transformation and interpretation.

Example

The following example SPARQL query could help model the question "What is within the bounding box defined by 38°54′49″N 77°05′20″W / 38.913574°N 77.089005°W and 38°53′11″N 77°01′48″W / 38.886321°N 77.029953°W?"

<span id="mwVA"></span><span class="k" id="mwVQ">PREFIX</span> <span class="nn" id="mwVg">geo</span><span class="p" id="mwVw">:</span> <span class="nl" id="mwWA"><http://www.opengis.net/ont/geosparql#></span> <span class="k" id="mwWQ">PREFIX</span> <span class="nn" id="mwWg">geof</span><span class="p" id="mwWw">:</span> <span class="nl" id="mwXA"><http://www.opengis.net/def/function/geosparql/></span> <span class="k" id="mwXQ">SELECT</span> <span class="nv" id="mwXg">?what</span> <span class="k" id="mwXw">WHERE</span> <span class="p" id="mwYA">{</span> <span class="nv" id="mwYQ">?what</span> <span class="nn" id="mwYg">geo</span><span class="p" id="mwYw">:</span><span class="nt" id="mwZA">hasGeometry</span> <span class="nv" id="mwZQ">?geometry</span> <span class="p" id="mwZg">.</span> <span class="k" id="mwZw">FILTER</span><span class="p" id="mwaA">(</span><span class="nn" id="mwaQ">geof</span><span class="p" id="mwag">:</span><span class="nt" id="mwaw">sfWithin</span><span class="p" id="mwbA">(</span><span class="nv" id="mwbQ">?geometry</span><span class="p" id="mwbg">,</span> <span class="s" id="mwbw">"POLYGON((-77.089005 38.913574,-77.029953 38.913574,-77.029953 38.886321,-77.089005 38.886321,-77.089005 38.913574))"</span><span class="o" id="mwcA">^^</span><span class="nn" id="mwcQ">geo</span><span class="p" id="mwcg">:</span><span class="nt" id="mwcw">wktLiteral</span><span class="p" id="mwdA">))</span> <span class="p" id="mwdQ">}</span>

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Geography