OWLIM-SE Geo-spatial Extensions

Skip to end of metadata
Go to start of metadata
This documentation is NOT for the latest version of GraphDB.

Latest version - GraphDB 7.1

OWLIM Documentation

Next versions

OWLIM 5.3
OWLIM 5.4

GraphDB 6.0 & 6.1
GraphDB 6.2
GraphDB 6.3
GraphDB 6.4
GraphDB 6.5
GraphDB 6.6
GraphDB 7.0
GraphDB 7.1

Previous versions

OWLIM 5.1
OWLIM 5.0
OWLIM 4.4
OWLIM 4.3
OWLIM 4.2
OWLIM 4.1
OWLIM 4.0

OWLIM-SE has special support for 2-dimensional geo-spatial data that uses the WGS84 Geo Positioning RDF vocabulary (World Geodetic System 1984). Special indices can be used for this data that permit the efficient evaluation of special query forms and extension functions that allow:

  • locations to be found that are within a certain distance of a point, i.e. within the specified circle on the surface of the sphere (Earth), using the nearby(...) construction;
  • locations that are within rectangles and polygons, where the vertices are defined using spherical polar coordinates, using the within(...) construction.
The following jar files (included with the OWLIM distribution) must be on the classpath in order for the geo-spatial extensions to function correctly: jsi-1*.jar, log4j-1*.jar, sil-0*.jar, trove4j-2*.jar

The WGS84 ontology can be found at: http://www.w3.org/2003/01/geo/wgs84_pos and contains several classes and predicates:

Element Description
SpatialThing Class used to represent anything with spatial extent, i.e. size, shape or position.
Point Class used represent a point (relative to Earth) defined using latitude, longitude (and altitude).
subClassOf http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing
location The relation between a thing and where it is.
range SpatialThing
subPropertyOf http://xmlns.com/foaf/0.1/based_near
lat The WGS84 latitude of a SpatialThing (decimal degrees).
domain http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing
long The WGS84 longitude of a SpatialThing (decimal degrees).
domain http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing
lat_long A comma-separated representation of a latitude, longitude coordinate.
alt The WGS84 altitude of a SpatialThing (decimal meters above the local reference ellipsoid).
domain http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing

Before the geo-spatial extensions can be used, the geo-spatial index must be built. This is achieved by inserting and committing a dummy statement (that is not actually stored) that uses a special predicate:

PREFIX ontogeo: <http://www.ontotext.com/owlim/geo#>
INSERT DATA { _:b1 ontogeo:createIndex _:b2. }

If the indexing is successful, the above update will succeed, otherwise an exception will be thrown. Information about the indexing process and any errors can be found in the log. Note that this update will fail if there is no geo-spatial data in the repository, i.e. no statements describing resources with latitude and longitude properties.

Geo-spatial query syntax

The special syntax used to query geo-spatial data makes use of SPARQL's RDF Collections syntax. This syntax uses round brackets as a shorthand for the statements connecting a list of values using rdf:first and rdf:rest predicates with terminating rdf:nil. Statement patterns that use one of the special geo-spatial predicates supported by OWLIM-SE are treated differently by the query engine. The following special syntax is supported when evaluating SPARQL queries (the descriptions all use the namespace:

omgeo: <http://www.ontotext.com/owlim/geo#>

Construct Nearby (lat long distance)
Syntaxt ?point omgeo:nearby(?lat ?long ?distance)
Description This statement pattern will evaluate to true if the following constraints hold:
  • ?point geo:lat ?plat .
  • ?point geo:long ?plong .
  • Shortest great circle distance from (?plat, ?plong) to (?lat, ?long) <= ?distance

    Such a construction will use the geo-spatial indices to find bindings for ?point that lie within the defined circle.
    Constants are allowed for any of ?lat ?long ?distance, where latitude and longitude are specified in decimal degrees and distance is specified in either kilometres ('km' suffix) or miles ('mi' suffix). If the units are not specified, then 'km' is assumed.
Restrictions Latitude is limited to the range -90 (South) to +90 (North)
Longitude is limited to the range -180 (West) to +180 (East)
Examples Find the names of airports that are within 50 miles of Seoul:
PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo-ont: <http://www.geonames.org/ontology#>
PREFIX omgeo: <http://www.ontotext.com/owlim/geo#>
SELECT distinct ?airport
WHERE {
  ?base geo-ont:name "Seoul" .
  ?base geo-pos:lat ?latBase .
  ?base geo-pos:long ?longBase .
  ?link omgeo:nearby(?latBase ?longBase "50mi") .
  ?link geo-ont:name ?airport  .
  ?link geo-ont:featureCode geo-ont:S.AIRP .
}



Construct Within (rectangle)
Syntax ?point omgeo:within(?lat1 ?long1 ?lat2 ?long2)
Description This statement pattern is used to test/find points that lie within the rectangle specified by diagonally opposite corners ?lat1 ?long1 and ?lat2 ?long2. The corners of the rectangle must be either constants or bound values.
It will evaluate to true if the following constraints hold:
  • ?point geo:lat ?plat .
  • ?point geo:long ?plong .
  • ?lat1 <= ?plat <= ?lat2
  • ?long1 <= ?plong <= ?long2

    Note that the corners must be specified most westerly and southerly (first) and most northerly and easterly (second). Proper account is taken for rectangles that cross the +/-180 degree meridian.
    Constants are allowed for any of ?lat1 ?long1 ?lat2 *long2, where latitude and longitude are specified in decimal degrees. If ?point is unbound then bindings for all points within the rectangle will be produced.
Restrictions Latitude is limited to the range -90 (South) to +90 (North)
Longitude is limited to the range -180 (West) to +180 (East)
Rectangle vertices must be specified in the order lower-left followed by upper-right
Examples Find tunnels lying within a rectangle enclosing Tirol, Austria:
PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo-ont: <http://www.geonames.org/ontology#>
PREFIX omgeo:   <http://www.ontotext.com/owlim/geo#>
SELECT ?feature ?lat ?long
WHERE {
  ?link omgeo:within(45.85 9.15 48.61 13.18) .
  ?link geo-ont:featureCode geo-ont:R.TNL .
  ?link geo-ont:name ?feature .
  ?link geo-pos:lat ?lat .
  ?link geo-pos:long ?long .
}


Construct Within (polygon)
Syntax ?point omgeo:within(?lat1 ?long1 ... ?latn ?longn)
Description This statement pattern is used to test/find points that lie within the polygon whose vertices are specified by three or more latitude/longitude pairs. The values for the vertices must be either constants or bound values.
It will evaluate to true if the following constraints hold:
  • ?point geo:lat ?plat .
  • ?point geo:long ?plong .
  • the position ?plat ?plong is enclosed by the polygon
    The polygon is closed automatically if the first and last vertices do not coincide. The vertices must be constants or bound values. Coordinates are specified in decimal degrees. If ?point is unbound then bindings for all points within the polygon will be produced.
Restrictions Latitude is limited to the range -90 (South) to +90 (North)
Longitude is limited to the range -180 (West) to +180 (East)
Examples Find caves in the sides of cliffs lying within a polygon approximating the shape of England:
PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo-ont: <http://www.geonames.org/ontology#>
PREFIX omgeo:   <http://www.ontotext.com/owlim/geo#>
SELECT ?feature ?lat ?long
WHERE {
?link omgeo:within( "51.45" "-2.59"
  "54.99" "-3.06"
  "55.81" "-2.03"
  "52.74"  "1.68"
  "51.17"  "1.41" ) .
  ?link geo-ont:featureCode geo-ont:S.CAVE .
  ?link geo-ont:name ?feature .
  ?link geo-pos:lat ?lat .
  ?link geo-pos:long ?long .
}

Extension query functions

At present there is just one SPARQL extension function.

Function Distance function
Syntax double omgeo:distance(?lat1, ?long1, ?lat2, ?long2)
Description This SPARQL extension function computes the distance between two points in kilometres and can be used in FILTER and ORDER BY clauses.
Restrictions Latitude is limited to the range -90 (South) to +90 (North)
Longitude is limited to the range -180 (West) to +180 (East)
Examples Find all the airports within 80 miles of Bournemouth and filter out those that are more than 80 kilometres from Brize Norton, order the results with the closest to Brize Norton first:
PREFIX geo-pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geo-ont: <http://www.geonames.org/ontology#>
PREFIX omgeo:   <http://www.ontotext.com/owlim/geo#>

SELECT distinct ?airport_name
WHERE {
  ?a1 geo-ont:name "Bournemouth" .
  ?a1 geo-pos:lat ?lat1 .
  ?a1 geo-pos:long ?long1 .
  ?airport omgeo:nearby(?lat1 ?long1 "80mi" ) .
  ?airport geo-ont:name ?airport_name .
  ?airport geo-ont:featureCode geo-ont:S.AIRP .
  ?airport geo-pos:lat ?lat2 .
  ?airport geo-pos:long ?long2 .
  ?a2 geo-ont:name "Brize Norton" .
  ?a2 geo-pos:lat ?lat3 .
  ?a2 geo-pos:long ?long3 .
  FILTER( omgeo:distance(?lat2, ?long2, ?lat3, ?long3) < 80)
}
ORDER BY ASC( omgeo:distance(?lat2, ?long2, ?lat3, ?long3) )

Implementation details

Knowledge of the implementation's algorithms and assumptions will allow users to make the best use of the OWLIM-SE geo-spatial extensions. The following points are significant and can affect the expected behaviour during query answering:

  • Spherical Earth – the current implementation treats the Earth as a perfect sphere with a radius of 6371.009km;
  • Only 2-Dimensional points are supported, i.e. there is no special handling of geo:alt (metres above the reference surface of the Earth);
  • All latitude and longitude values must be specified using decimal degrees, where East and North are positive and -90 <= latitude <= +90 and -180 <= longitude <= +180;
  • Distances must be in units of kilometres (suffix 'km') or statute miles (suffix 'mi'). If the suffix is omitted, kilometres are assumed;
  • omgeo:within( rectangle ) construct uses a 'rectangle' whose edges are lines of latitude and longitude, so the north-south distance is constant and the rectangle described forms a band around the Earth that starts and stops at the given longitudes;
  • omgeo:within( polygon ) joins vertices with straight lines on a cylindrical projection of the Earth tangential to the equator. A straight line starting at the point under test and continuing East out of the polygon is examined to see how many polygon edges it intersects. If the number of intersections is even then the point is outside the polygon, if the number of intersections is odd, the point is inside the polygon. With the current algorithm, the order of vertices is not relevant (clockwise or anticlockwise);
  • omgeo:within() may not work correctly when the region (polygon or rectangle) spans the +/-180 meridian;
  • omgeo:nearby() uses the great circle distance between points.
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.