{toc}
h1. Overview
*{_}GeoSPARQL{_}* is a standard for representation and querying of geospatial linked data for the Semantic Web from the Open Geospatial Consortium (OGC).The standard provides:
* a small topological ontology in RDFS/OWL for representation using [Geography Markup Language (GML) |https://en.wikipedia.org/wiki/Geography_Markup_Language] and [Well-Known Text (WKT) |https://en.wikipedia.org/wiki/Well-known_text] literals
* Simple Features, RCC8, and DE-9IM (a.k.a. Egenhofer) topological relationship vocabularies and ontologies for qualitative reasoning
* a SPARQL query interface using a set of topological SPARQL extension functions for quantitative reasoning
A simplified diagram of some geometry classes and properties:
!GeoSPARQL-geometry.PNG|width=700!
GraphDB 6.5 introduces support for GeoSPARQL.
h1. Installation
The GeoSPARQL support is implemented as a GraphDB plugin, which is currently not installed by default. To install the plugin follow these steps:
# Locate the plugin {{zip}} file in the {{plugins/geosparql}} folder of the GraphDB distribution.
# Unzip the file into your plugins directory (by default {{root_of_unpacked_web_app/WEB-INF/classes/plugins}}).
{note}
Note that you still have to enable the plugin after you install it. See [#Enable plugin] for more information.
{note}
h1. Usage
h3. Plugin control predicates
The plugin allows you to configure it through SPARQL-Update queries with embedded control predicates:
h4. Enable plugin
When the plugin is enabled it will index all existing GeoSPARQL data in the repository and automatically reindex any updates.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :enabled "true" .
}
{code}
h4. Disable plugin
When the plugin is disabled it will not index any data or process updates. It will not handle any of the GeoSPARQL predicates either.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :enabled "false" .
}
{code}
h4. Force reindex GeoSPARQL geometry data
Usually this is a configuration option which could be used in cases where your index files
are either corrupted or have been mistakenly deleted.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :forceReindex ""
}
{code}
h3. GeoSPARQL Predicates
Some examples of select queries on geographic data. For demo purposes just import the following files:
* [GeoSPARQL support^simple_features_geometries.rdf]
* [GeoSPARQL support^geosparql-example.rdf]
and run the following queries queries on them:
* Example 1
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
my:A my:hasExactGeometry ?aGeom .
?aGeom geo:asWKT ?aWKT .
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (geof:sfContains(?aWKT, ?fWKT) && !sameTerm(?aGeom, ?fGeom))
}
{code}
* Example 2
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
?f my:hasPointGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (geof:sfWithin(?fWKT, '''
<http://www.opengis.net/def/crs/OGC/1.3/CRS84>
Polygon ((-83.4 34.0, -83.1 34.0, -83.1 34.2, -83.4 34.2, -83.4 34.0))
'''^^geo:wktLiteral))
}
{code}
* Example 3
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
my:A my:hasExactGeometry ?aGeom .
?aGeom geo:asWKT ?aWKT .
my:D my:hasExactGeometry ?dGeom .
?dGeom geo:asWKT ?dWKT .
FILTER (geof:sfTouches(?fWKT, geof:union(?aWKT, ?dWKT)))
}
{code}
* Example 4
{code}
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
my:C my:hasExactGeometry ?cGeom .
?cGeom geo:asWKT ?cWKT .
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (?fGeom != ?cGeom)
} ORDER BY ASC(geof:distance(?cWKT, ?fWKT, uom:metre)) LIMIT 3
{code}
* Example 5
{code}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX my: <http://example.org/ApplicationSchema#>
SELECT ?f
WHERE {
?f geo:sfOverlaps my:AExactGeom
}
{code}
* Example 6
{note}
Using geometry literals in the object position is a GraphDB extension and not part of the GeoSPARQL specification.
{note}
{code}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX my: <http://example.org/ApplicationSchema#>
SELECT ?f
WHERE {
?f geo:sfOverlaps "Polygon((-83.6 34.1, -83.2 34.1, -83.2 34.5, -83.6 34.5, -83.6 34.1))"^^geo:wktLiteral
}
{code}
For more information regarding GeoSPARQL predicates and functions please look at the [current official spec |http://www.opengis.net/doc/IS/geosparql/1.0]: OGC 11-052r4, Version: 1.0, Approval Date: 2012-04-27, Publication Date: 2012-09-10.
h1. Overview
*{_}GeoSPARQL{_}* is a standard for representation and querying of geospatial linked data for the Semantic Web from the Open Geospatial Consortium (OGC).The standard provides:
* a small topological ontology in RDFS/OWL for representation using [Geography Markup Language (GML) |https://en.wikipedia.org/wiki/Geography_Markup_Language] and [Well-Known Text (WKT) |https://en.wikipedia.org/wiki/Well-known_text] literals
* Simple Features, RCC8, and DE-9IM (a.k.a. Egenhofer) topological relationship vocabularies and ontologies for qualitative reasoning
* a SPARQL query interface using a set of topological SPARQL extension functions for quantitative reasoning
A simplified diagram of some geometry classes and properties:
!GeoSPARQL-geometry.PNG|width=700!
GraphDB 6.5 introduces support for GeoSPARQL.
h1. Installation
The GeoSPARQL support is implemented as a GraphDB plugin, which is currently not installed by default. To install the plugin follow these steps:
# Locate the plugin {{zip}} file in the {{plugins/geosparql}} folder of the GraphDB distribution.
# Unzip the file into your plugins directory (by default {{root_of_unpacked_web_app/WEB-INF/classes/plugins}}).
{note}
Note that you still have to enable the plugin after you install it. See [#Enable plugin] for more information.
{note}
h1. Usage
h3. Plugin control predicates
The plugin allows you to configure it through SPARQL-Update queries with embedded control predicates:
h4. Enable plugin
When the plugin is enabled it will index all existing GeoSPARQL data in the repository and automatically reindex any updates.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :enabled "true" .
}
{code}
h4. Disable plugin
When the plugin is disabled it will not index any data or process updates. It will not handle any of the GeoSPARQL predicates either.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :enabled "false" .
}
{code}
h4. Force reindex GeoSPARQL geometry data
Usually this is a configuration option which could be used in cases where your index files
are either corrupted or have been mistakenly deleted.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :forceReindex ""
}
{code}
h3. GeoSPARQL Predicates
Some examples of select queries on geographic data. For demo purposes just import the following files:
* [GeoSPARQL support^simple_features_geometries.rdf]
* [GeoSPARQL support^geosparql-example.rdf]
and run the following queries queries on them:
* Example 1
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
my:A my:hasExactGeometry ?aGeom .
?aGeom geo:asWKT ?aWKT .
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (geof:sfContains(?aWKT, ?fWKT) && !sameTerm(?aGeom, ?fGeom))
}
{code}
* Example 2
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
?f my:hasPointGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (geof:sfWithin(?fWKT, '''
<http://www.opengis.net/def/crs/OGC/1.3/CRS84>
Polygon ((-83.4 34.0, -83.1 34.0, -83.1 34.2, -83.4 34.2, -83.4 34.0))
'''^^geo:wktLiteral))
}
{code}
* Example 3
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
my:A my:hasExactGeometry ?aGeom .
?aGeom geo:asWKT ?aWKT .
my:D my:hasExactGeometry ?dGeom .
?dGeom geo:asWKT ?dWKT .
FILTER (geof:sfTouches(?fWKT, geof:union(?aWKT, ?dWKT)))
}
{code}
* Example 4
{code}
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT ?f
WHERE {
my:C my:hasExactGeometry ?cGeom .
?cGeom geo:asWKT ?cWKT .
?f my:hasExactGeometry ?fGeom .
?fGeom geo:asWKT ?fWKT .
FILTER (?fGeom != ?cGeom)
} ORDER BY ASC(geof:distance(?cWKT, ?fWKT, uom:metre)) LIMIT 3
{code}
* Example 5
{code}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX my: <http://example.org/ApplicationSchema#>
SELECT ?f
WHERE {
?f geo:sfOverlaps my:AExactGeom
}
{code}
* Example 6
{note}
Using geometry literals in the object position is a GraphDB extension and not part of the GeoSPARQL specification.
{note}
{code}
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX my: <http://example.org/ApplicationSchema#>
SELECT ?f
WHERE {
?f geo:sfOverlaps "Polygon((-83.6 34.1, -83.2 34.1, -83.2 34.5, -83.6 34.5, -83.6 34.1))"^^geo:wktLiteral
}
{code}
For more information regarding GeoSPARQL predicates and functions please look at the [current official spec |http://www.opengis.net/doc/IS/geosparql/1.0]: OGC 11-052r4, Version: 1.0, Approval Date: 2012-04-27, Publication Date: 2012-09-10.