|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Changes (33)
View Page History
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.
* 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 enabled installed by default. To enable install the plugin follow these steps:
# Locate the plugin {{zip}} file in the {{plugins/geosparql-plugin}} folder of the GraphDB distribution.
# Unzip the file into your plugins directory (by default *{{root_of_unpacked_web_app/WEB-INF/classes/plugins}}*). {{root_of_unpacked_web_app/WEB-INF/classes/plugins}}).
h1. Usage examples
{note}
Note that you still have to enable the plugin after you install it. See [#Enable plugin] for more information.
{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

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#>
PREFIX : <http://www.ontotext.com/plugins/geosparql#>

{code}
NOTE: The object literal can be written also as an _xsd boolean_ type by including a _xsd_ prefix:
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#>
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
INSERT DATA {
_:s :enabled "true"^^xsd:boolean "false" .
}
{code}
{code}
h4. Disable plugin
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.
are either corrupted or have been mistakenly deleted.
{code}
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
PREFIX : <http://www.ontotext.com/plugins/geosparql#>
INSERT DATA {
_:s :enabled "false" .
_:s :forceReindex ""
}
{code}
{code}
NOTE: The object literal can be written also as an _xsd boolean_ type by including a _xsd_ prefix:
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
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 : <http://www.ontotext.com/plugins/geosparql#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
INSERT DATA {
_:s :enabled "false"^^xsd:boolean .
_:s :enabled "false"^^xsd:boolean .
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))
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}
{code}
h4. Force Reindex GeoSPARQL geometry data
* 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/>
{code}
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
Usually this is a configuration option which could be used in cases where your index files
are either corrupted or have been mistakenly deleted.
are either corrupted or have been mistakenly deleted.
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}
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 : <http://www.ontotext.com/plugins/geosparql#>
PREFIX my: <http://example.org/ApplicationSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
INSERT DATA {
_:s :forceReindex ""
_:s :forceReindex ""
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)))
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}
{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.