GeoSPARQL Functions
The geoSPARQL functions follow the world-wide geospatial standard (https://www.ogc.org/standards/geosparql/) developed and promoted by the Open Geospatial Consortium (OGC) community to represent geospatial data in RDF format and query that data using the SPARQL query language.
Classes, Data Types, and Properties
This section provides a summary of the geometry shape classes, subclasses, data types, properties, and relationships that geoSPARQL functions operate on.
OWL classes and subclasses
The GeoSPARQL OWL specification describes various classes that are supported (for example, geo:SpatialObject
and geo:Feature
), their subclasses (geo:Geometry
), and associated properties and relationships (geo:hasGeometry
, geo:hasDefaultGeometry
, geo:dimension
, geo:coordinateDimension
, geo:spatialDimension
, geo:isEmpty
, geo:isSimple
, geo:hasSerialization
).
GeoSPARQL RDF data must also conform to the OWL representation and implement the features and properties as described in the OGC GeoSPARQL specification.
Data Types
GeoSPARQL uses some custom data types, namely, geo:wktLiteral
and geo:gmlLiteral
to represent serialized geometry shapes in text form. Function arguments that specify geometries may pass those objects as wktLiteral
, gmlLiteral
, or string literals defined in the <http://www.opengis.net/ont/geosparql#>
namespace. Units of measurement (UOM) such as kilometer, meter, mile, degree, and radian are defined in the <http://www.opengis.net/def/uom/OGC/1.0/>
namespace.
In Graph Lakehouse, these literals are represented as RDFLiteral
objects, which is a combination of a string and a data type URI. All of the geometries are represented in the graph as either WKT (well-known-text format) or GML (Geometry Markup Language) serialization forms. They may also be represented as objects or string literals.
Relational Properties
GeoSPARQL introduces a set of properties to be used in SPARQL graph patterns. There are three types of relational families: Simple Features (sf), Egenhofer (eh), and RCC8 (rcc8).
For additional information on the operation of functions, see the Geographic Query Language for RDF Data specification.
Functions
The geoSPARQL functions are grouped by the following categories:
The URI for the geoSPARQL functions is <http://www.opengis.net/def/function/geosparql/>
. For readability, the syntax for each function below includes the prefix geof:
, defined as PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
.
Non-Topological Functions
- distance: Computes the shortest distance between two geometries.
- buffer:
Returns a geometric object that represents all points whose distance from a geometry is less than or equal to the specified radius.
- convexHull:
Returns a geometric object that represents all points in the convex hull of the specified geometry.
- intersection:
Returns all points that intersect two geometries.
- union:
Returns all points in the union of two geometries.
- difference:
Returns all points in the set of difference between two geometries.
- symDifference: Returns all points in the set of symmetric difference between two geometries.
- envelope: Returns the minimum bounding box of the specified geometry.
- boundary: Returns the closure of the boundary of the specified geometry.
- getSRID: Returns the spatial reference system URI for the specified geometry.
- relate: Evaluates whether the spatial relationship between the specified geometries corresponds to the specified pattern matrix.
distance
This function takes two geometries as input and computes the shortest distance between them based on the SRID of the first geometry. The function converts the distance in meters to the specified unit of measure.
Syntax
geof:distance(geom1, geom2, units)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
units
|
URI |
The unit of measure in OGC format. |
If no SRID is specified in geom1 or geom2, the function assumes CRS84
as the default unit of measure and assumes coordinates in Long, Lat format. If geom1 and geom2 are specified as WKT strings and no SRID details are provided, the function computes the Euclidean distance between the two geometries regardless of what unit of measure is provided.
To find the spherical distance between two geometries, you can use 4047
as the SRID. The 4047 value specifies a spherical coordinate system number. The spherical distance gets computed based on Great circle algorithms, and Planer geodesics distances are computed using ellipsoidal formulas.
Returns
double |
The shortest distance. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT (geof:distance(?x,?y,?z) as ?distance)
WHERE {
VALUES (?x ?y ?z) {
('<http://www.opengis.net/def/crs/EPSG/0/4326>Point (0 0)' '<http://www.opengis.net/def/crs/EPSG/0/4326>Point (3 4)' uom:millimeter)
('<http://www.opengis.net/def/crs/EPSG/0/4326>Point (0 0)' '<http://www.opengis.net/def/crs/EPSG/0/4326>Point (3 4)' uom:kilometer)
('<http://www.opengis.net/def/crs/EPSG/0/4326>Point (0 0)' '<http://www.opengis.net/def/crs/EPSG/0/4326>Point (3 4)' uom:metre)
('<http://www.opengis.net/def/crs/EPSG/0/4326>Point (0 0)' '<http://www.opengis.net/def/crs/EPSG/0/4326>Point (3 4)' uom:foot)
}
}
buffer
This function takes a geomLiteral and radius argument in a given unit of measure and produces a polygon of points that has a distance less than or equal to the given radius from a central geomLiteral position. The input radius is converted from the source unit of measure based on 1° equal to 111 km and returns the polygon of points less than or equal to the distance from the geomLiteral position on an XY plane.
Syntax
geof:buffer(geom, radius, units)
geom
|
geomLiteral |
The geometry. |
radius
|
double |
The radius of the geometry. |
units
|
URI |
The unit of measure in OGC format. |
Returns
geomLiteral |
Polygon of points. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
PREFIX uom: <http://www.opengis.net/def/uom/OGC/1.0/>
SELECT (geof:buffer(?x,?y,?z) as ?buffer)
WHERE {
VALUES (?x ?y ?z) {
('Point (0 0)' 2 uom:meter)
('POLYGON ((1 1 , 1 4, 4 4, 4 1))'^^geo:wktLiteral 20 uom:millimeter)
}
}
convexHull
This function returns a geometric object that represents all points in the convex hull of the geometry. Calculations are in the spatial reference system of the specified geometry.
Syntax
geof:convexHull(geom)
geom
|
geomLiteral |
The geometry. |
Returns
geomLiteral |
All points in the convex hull. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:convexHull(?x) as ?convexHull)
WHERE {
VALUES (?x) {
('POINT(1 2)')
('<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
('POLYGON ((1 1 , 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
intersection
This function returns a geometric object that represents all points in the intersection of the input geometries. Calculations are in the spatial reference system of the first geometry.
Syntax
geof:intersection(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
geomLiteral |
All points in the intersection. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:intersection(?x,?y) as ?intersection)
WHERE {
VALUES (?x ?y) {
('LINESTRING (8 7, 7 8)' 'LINESTRING (2 0, 2 3)')
('LINESTRING (0 2, 0 0, 2 0)' 'LINESTRING (0 3, 0 1, 1 0, 3 0)')
}
}
union
This function returns a geometric object that represents all points in the union of two geometries. Calculations are in the spatial reference system of the first geometry.
Syntax
geof:union(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
geomLiteral |
All points in the union. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:union(?x,?y) as ?union)
WHERE {
VALUES (?x ?y) {
('<http://www.opengis.net/def/crs/EPSG/0/4326>LINESTRING (8 7, 7 8)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
('LINESTRING (0 2, 0 0, 2 0)'^^geo:wktLiteral 'LINESTRING (0 3, 0 1, 1 0, 3 0)'^^geo:wktLiteral)
}
}
difference
This function returns a geometric object that represents all points in the set of difference between two geometries. Calculations are in the spatial reference system of the first geometry.
Syntax
geof:difference(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
geomLiteral |
All points in the set of difference. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:difference(?x,?y) as ?intersection)
WHERE {
VALUES (?x ?y) {
('<http://www.opengis.net/def/crs/EPSG/0/4326>LINESTRING (8 7, 7 8)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
('LINESTRING (0 2, 0 0, 2 0)'^^geo:wktLiteral 'LINESTRING (0 3, 0 1, 1 0, 3 0)'^^geo:wktLiteral)
}
}
symDifference
This function returns a geometric object that represents all points in the set of symmetric difference between two geometries. Calculations are in the spatial reference system of the first geometry.
Syntax
geof:symDifference(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
geomLiteral |
All points in the symmetric difference. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:symDifference(?x,?y) as ?symdiff)
WHERE {
VALUES (?x ?y) {
('<http://www.opengis.net/def/crs/EPSG/0/4326>LINESTRING (8 7, 7 8)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
('LINESTRING (0 2, 0 0, 2 0)'^^geo:wktLiteral 'LINESTRING (0 3, 0 1, 1 0, 3 0)'^^geo:wktLiteral)
}
}
envelope
This function returns the minimum bounding box of the specified geometry.
Syntax
geof:envelope(geom)
geom
|
geomLiteral |
The geometry. |
Returns
geomLiteral |
The minimum bounding box. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:envelope(?x) as ?envelope)
WHERE {
VALUES (?x) {
('POLYGON ((2 0, 2 3, 3 0))'^^geo:wktLiteral) ('POLYGON ((2 0, 2 1, 3 1))')
}
}
boundary
This function returns the closure of the boundary of the specified geometry.
Syntax
geof:boundary(geom)
geom
|
geomLiteral |
The geometry. |
Returns
geomLiteral |
The closure of the boundary. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:boundary(?x) as ?boundary)
WHERE {
VALUES (?x) {
('POLYGON ((2 0, 2 3, 3 0))'^^geo:wktLiteral) ('<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
}
}
getSRID
This function returns the spatial reference system URI for the specified geometry.
Syntax
geof:getSRID(geom)
geom
|
geomLiteral |
The geometry. |
Returns
URI |
The spatial reference system URI. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:getSRID(?x) as ?srid)
WHERE {
VALUES (?x) {
('POLYGON ((2 0, 2 3, 3 0))'^^geo:wktLiteral) ('<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
}
}
relate
This function evaluates whether the spatial relationship between the specified geometries relates to the specified pattern matrix. The spatial reference system for the first geometry is used for spatial calculations.
Syntax
geof:relate(geom1, geom2, "pattern_matrix")
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
pattern_matrix
|
string |
Represents a DE-9IM intersection pattern consisting of T (true) and F (false) values. For example, "T*F***FF*" . |
Returns
boolean |
True if the spatial relationship relates to the specified pattern matrix. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:relate(?x,?y,"T*F**FFF*") as ?relate)
WHERE {
VALUES (?x ?y) {
('<http://www.opengis.net/def/crs/EPSG/0/4326>LINESTRING (2 0, 2 3)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
('LINESTRING (0 2, 0 0, 2 0)'^^geo:wktLiteral 'LINESTRING (0 3, 0 1, 1 0, 3 0)'^^geo:wktLiteral)
}
}
Simple Feature Family (Topological) Functions
The Simple Feature Family relation functions test DE-9IM intersection patterns between two geometries. Each function tests a different pattern matrix and returns true or false depending on whether the specified relation exists or not. Multi-row intersection patterns should be interpreted as a logical OR of each row. Click a function name in the list below to view the syntax and see details about function arguments and return values.
- sfEquals: Tests whether the specified geometries are equal.
- sfDisjoint: Tests whether the specified geometries are disjoint.
- sfIntersects: Tests whether the specified geometries intersect.
- sfTouches: Tests whether the specified geometries touch.
- sfCrosses: Tests whether the first geometry spatially crosses the second geometry.
- sfWithin: Tests whether the first geometry is spatially within the second geometry.
- sfContains: Tests whether the first geometry spatially contains the second geometry.
- sfOverlaps: Tests whether the first geometry spatially overlaps the second geometry.
sfEquals
This function tests whether the specified geometries are equal. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFFFTFFFT
.
Syntax
geof:sfEquals(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries are equal. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfEquals(?x,?y) as ?is_equal)
WHERE {
VALUES (?x ?y) {
('Point (2 3)' 'Point (2 3)')
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>2,3</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
}
}
sfDisjoint
This function tests whether the specified geometries are disjoint. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is FF*FF****
.
Syntax
geof:sfDisjoint(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries are disjoint. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfDisjoint(?x,?y) as ?is_disjoint)
WHERE {
VALUES (?x ?y) {
('LINESTRING (0 0, 0 1)' 'LINESTRING (1 0, 0 1)')
('<http://www.opengis.net/def/crs/EPSG/0/4326>LINESTRING (1 1, 1 0)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>0,0 0,1</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
}
}
sfIntersects
This function tests whether the specified geometries intersect. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is as follows:
T********
*T*******
***T*****
****T****
Syntax
geof:sfIntersects(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries intersect. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfIntersects(?x,?y) as ?intersects)
WHERE {
VALUES (?x ?y) {
('LINESTRING (8 7, 7 8)' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 4 1, 4 4, 1 4))'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
}
}
sfTouches
This function tests whether the specified geometries touch. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is as follows:
FT*******
F**T*****
F***T****
Syntax
geof:sfTouches(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries touch. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfTouches(?x,?y) as ?touches)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'Point (1 2)')
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((30 10 , 40 40, 20 40, 10 20, 30 10))'^^geo:wktLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>-106.4453583,39.11775</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
}
}
sfCrosses
This function tests whether the first geometry spatially crosses the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is as follows:
For P/L, P/A, L/A:
T*T***T**
For L/L:
0*T***T**
Syntax
geof:sfCrosses(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry spatially crosses the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfCrosses(?x,?y) as ?crosses)
WHERE {
VALUES (?x ?y) {
('LINESTRING (2 0, 2 3)' 'POLYGON ((30 10 , 40 40, 20 40, 10 20, 30 10))')
('<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>2,0 2,3</gml:coordinates></gml:LineString>'^^geo:gmlLiteral '<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1 , 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
sfWithin
This function tests whether the first geometry is spatially within the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is T*F**F***
.
Syntax
geof:sfWithin(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry is spatially within the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfWithin(?x,?y) as ?is_within)
WHERE {
VALUES (?x ?y) {
('Point (-106.4453583 39.11775)' 'POLYGON ((30 10 , 40 40, 20 40, 10 20, 30 10))')
('<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>2,3</gml:coordinates></gml:Point>'^^geo:gmlLiteral '<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
sfContains
This function tests whether the first geometry spatially contains the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is T*****FF*
.
Syntax
geof:sfContains(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry spatially contains the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfContains(?x,?y) as ?contains)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral 'Point (2 3)'^^geo:wktLiteral)
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>2,3</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
('<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>45.67,88.56 55.56,89.44</gml:coordinates></gml:LineString>'^^geo:gmlLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>45.67,88.56</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
}
}
sfOverlaps
This function tests whether the first geometry spatially overlaps the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is as follows:
For A/A, P/P:
T*T***T**
For L/L:
1*T***T**
Syntax
geof:sfOverlaps(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry spatially overlaps the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:sfOverlaps(?x,?y) as ?overlaps)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 0, 2 1, 1 3))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('POLYGON ((2 0, 2 1, 3 1))'^^geo:wktLiteral 'POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
Egenhofer Family (Topological) Functions
The Egenhofer Family relation functions test DE-9IM intersection patterns between two geometries. Each function tests a different pattern matrix and returns true or false depending on whether the specified relation exists or not. Multi-row intersection patterns should be interpreted as a logical OR of each row. Click a function name in the list below to view the syntax and see details about function arguments and return values.
- ehEquals: Tests whether the specified objects are equal.
- ehDisjoint: Tests whether the specified objects are disjoint.
- ehMeet: Tests whether the specified geometries meet.
- ehOverlap: Tests whether the specified geometries overlap.
- ehCovers:
Tests whether the first geometry spatially covers the second geometry.
- ehCoveredBy: Tests whether the first geometry is covered by the second geometry.
- ehInside: Tests whether the first geometry is inside the second geometry.
- ehContains: Tests whether the first geometry is contained in the second geometry.
ehEquals
This function tests whether the specified objects are equal based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFFFTFFFT
.
Syntax
geof:ehEquals(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the objects are equal. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehEquals(?x,?y) as ?is_equals)
WHERE {
VALUES (?x ?y) {
('Point (2 3)' 'Point (2 3)')
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>2,3</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
}
}
ehDisjoint
This function tests whether the specified objects are disjoint based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is FF*FF****
.
Syntax
geof:ehDisjoint(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the objects are disjoint. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehDisjoint(?x,?y) as ?is_disjoint)
WHERE {
VALUES (?x ?y) {
('LINESTRING (0 0, 0 1)' 'LINESTRING (1 0, 0 1)')
('<http://www.opengis.net/def/crs/EPSG/0/4326> LINESTRING (1 1, 1 0)'^^geo:wktLiteral '<gml:LineString gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"><gml:coordinates>0,0 0,1</gml:coordinates></gml:LineString>'^^geo:gmlLiteral)
}
}
ehMeet
This function tests whether the specified geometries meet based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is as follows:
FT*******
F**T*****
F***T****
Syntax
geof:ehMeet(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries meet. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehMeet(?x,?y) as ?meets)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'Point (1 2)')
('<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((30 10 , 40 40, 20 40, 10 20, 30 10))'^^geo:wktLiteral '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>-106.4453583,39.11775</gml:coordinates></gml:Point>'^^geo:gmlLiteral)
}
}
ehOverlap
This function tests whether the specified geometries overlap based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is T*T***T**
.
Syntax
geof:ehOverlap(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries overlap. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehOverlap(?x,?y) as ?overlaps)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 0, 2 1, 1 3))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('LINESTRING(0 0, 4 4)'^^geo:wktLiteral 'POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
ehCovers
This function tests whether the first geometry spatially covers the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is T*TFT*FF*
.
Syntax
geof:ehCovers(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry spatially covers the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehCovers(?x,?y) as ?covers)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 0, 2 1, 1 3))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral 'LINESTRING(1 1, 4 4)'^^geo:wktLiteral)
('LINESTRING(1 1, 4 4)' 'LINESTRING(2 2, 4 4)')
('LINESTRING(3 3, 4 4)' 'LINESTRING(2 2, 4 4)')
}
}
ehCoveredBy
This function tests whether the first geometry is covered by the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFF*TFT**
.
Syntax
geof:ehCoveredBy(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry is covered by the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehCoveredBy(?x,?y) as ?is_covered)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 0, 2 1, 1 3))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('LINESTRING(1 1, 4 4)' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('LINESTRING(1 1, 4 4)' 'LINESTRING(2 2, 4 4)')
('LINESTRING(3 3, 4 4)' 'LINESTRING(2 2, 4 4)')
}
}
ehInside
This function tests whether the first geometry is inside the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFF*FFT**
.
Syntax
geof:ehInside(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry is inside the second geometry. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehInside(?x,?y) as ?is_inside)
WHERE {
VALUES (?x ?y) {
('Point (-106.4453583 39.11775)' 'POLYGON ((30 10 , 40 40, 20 40, 10 20, 30 10))')
('<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326"> <gml:coordinates>2,3</gml:coordinates></gml:Point>'^^geo:gmlLiteral '<http://www.opengis.net/def/crs/EPSG/0/4326>POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
ehContains
This function tests whether the first geometry is contained in the second geometry. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is T*TFF*FF*
.
Syntax
geof:ehContains(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the first geometry is contained in the second geometry. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:ehContains(geof:ST_GeomFromText(?x),geof:ST_GeomFromText(?y)) as ?contains)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'Point (2 3)')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'Point (7 8)')
}
}
RCC8 Family (Topological) Functions
The RCC8 Family relation functions test DE-9IM intersection patterns between two geometries. Each function tests a different pattern matrix and returns true or false depending on whether the specified relation exists or not. Click a function name in the list below to view the syntax and see details about function arguments and return values.
- rcc8eq: Tests whether the specified geometries are equal.
- rcc8dc: Tests whether the specified geometries are disjoint.
- rcc8ec: Tests whether the specified geometries are externally connected.
- rcc8po: Tests whether the specified geometries overlap.
- rcc8tpp: Tests whether one geometry is a tangential proper part of another geometry.
- rcc8tppi: Tests whether one geometry is a tangential proper part inverse of another geometry.
- rcc8ntpp: Tests whether one geometry is a non-tangential proper part of another geometry.
- rcc8ntppi: Tests whether one geometry is a non-tangential proper part inverse of another geometry.
rcc8eq
This function tests whether the specified objects are equal based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFFFTFFFT
.
Syntax
geof:rcc8eq(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the objects are equal. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8eq(?x,?y) as ?is_eq)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral 'POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
rcc8dc
This function tests whether the specified objects are disjoint based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is FFTFFTTTT
.
Syntax
geof:rcc8dc(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the objects are disjoint. False if not. |
Example
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8dc(?x,?y) as ?is_dc)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((11 11, 11 14, 14 14, 14 11))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral 'POLYGON ((1 1, 1 4, 4 4, 4 1))'^^geo:wktLiteral)
}
}
rcc8ec
This function tests whether the specified objects are externally connected based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is FFTFTTTTT
.
Syntax
geof:rcc8ec(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the objects are externally connected. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8ec(?x,?y) as ?is_ec)
WHERE {
VALUES (?x ?y) {
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((4 1, 6 1, 6 4, 4 4))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
}
}
rcc8po
This function tests whether the specified geometries overlap based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TTTTTTTTT
.
Syntax
geof:rcc8po(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the geometries overlap. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8po(?x,?y) as ?is_po)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 0, 2 1, 1 3,1 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((4 1, 6 1, 6 4, 4 4))')
}
}
rcc8tpp
This function tests whether one geometry is a tangential proper part of another geometry based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFFTTFTTT
.
Syntax
geof:rcc8tpp(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the second geometry is a tangential proper part of the first geometry. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8tpp(?x,?y) as ?is_tpp)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 2, 5 2, 5 4, 2 4))' 'POLYGON ((1 1, 1 6, 4 1, 4 6))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
}
}
rcc8tppi
This function tests whether one geometry is a tangential proper part inverse of another geometry based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TTTFTTFFT
.
Syntax
geof:rcc8tppi(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the second geometry is a tangential proper part inverse of the first geometry. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8tppi(?x,?y) as ?is_tppi)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 2, 5 2, 5 4, 2 4))' 'POLYGON ((1 1, 1 6, 4 1, 4 6))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
}
}
rcc8ntpp
This function tests whether one geometry is a non-tangential proper part of another geometry based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TFFTFFTTT
.
Syntax
geof:rcc8ntpp(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the second geometry is a non-tangential proper part of the first geometry. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8ntpp(?x,?y) as ?is_ntpp)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 2, 5 2, 5 4, 2 4))' 'POLYGON ((1 1, 1 6, 4 1, 4 6))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
}
}
rcc8ntppi
This function tests whether one geometry is a non-tangential proper part inverse of another geometry based on their associated primary geometry objects. The spatial reference system of the first geometry is used for spatial calculations. The defining DE-9IM intersection pattern is TTTFFTFFT
.
Syntax
geof:rcc8ntppi(geom1, geom2)
geom1
|
geomLiteral |
The first geometry. |
geom2
|
geomLiteral |
The second geometry. |
Returns
boolean |
True if the second geometry is a non-tangential proper part inverse of the first geometry. False if not. |
Example
PREFIX geof: <http://www.opengis.net/def/function/geosparql/>
SELECT (geof:rcc8ntppi(?x,?y) as ?is_ntppi)
WHERE {
VALUES (?x ?y) {
('POLYGON ((2 2, 5 2, 5 4, 2 4))' 'POLYGON ((1 1, 1 6, 4 1, 4 6))')
('POLYGON ((1 1, 1 4, 4 4, 4 1))' 'POLYGON ((1 1, 1 4, 4 4, 4 1))')
}
}