| Getting started |
A primary function of a geographic information system is determining the spatial relationships between features. The distance separating a hazardous waste disposal site and hospital, school, or housing development is an example of a spatial relationship.
Predicates are Boolean functions that return TRUE if a test passes and FALSE, otherwise, to determine if a specific relationship exists between a pair of geometries. Other functions return a value as a result of a spatial relationship. The result returned by the distance function, the space separating two geometries, is a double precision number. Alternatively, functions like intersection return a geometry as the result of combining two geometries.
Predicates return t (TRUE) if a comparison meets the functions criteria; otherwise, they return f (FALSE). Predicates that test for a spatial relationship compare pairs of geometry that can be a different type or dimension.
Predicates compare the X and Y coordinates of the submitted geometries. The Z coordinates and measure values, if they exist, are ignored. Geometries that have Z coordinates or measures can be compared with those that don't.
The Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini, et al., dimensionally extends the 9 Intersection Model of Egenhofer and Herring. DE-9IM is a mathematical approach that defines the pair-wise spatial relationship between geometries of different types and dimensions. This model expresses spatial relationships among all types of geometry as pair-wise intersections of their interior, boundary, and exterior with consideration for the dimension of the resulting intersections.
Predicates:
Related Concepts:
Example:
Given geometries a and b, I(a), B(a), and E(a) represent the interior, boundary, and exterior of a, and I(b), B(b), and E(b) represent the interior, boundary, and exterior of b. The intersections of I(a), B(a), and E(a) with I(b), B(b), and E(b) produces a 3-by-3 matrix. Each intersection can result in geometries of different dimensions. For example, the intersection of the boundaries of two polygons could consist of a point and a linestring, in which case the dim function would return the maximum dimension of 1.
The dim function returns a value of -1, 0, 1, or 2. The -1 corresponds to the null set that is returned when no intersection was found or dim(Æ).
Interior Boundary Exterior
Interior dim(I(a)ÇI(b)) dim(I(a)ÇB(b)) dim(I(a)ÇE(b))
Boundary dim(B(a)ÇI(b)) dim(B(a)ÇB(b)) dim(B(a)ÇE(b))
Exterior dim(E(a)ÇI(b)) dim(E(a)ÇB(b)) dim(E(a)ÇE(b))
The results of the spatial relationship predicates can be understood or verified by comparing the results of the predicate with a pattern matrix that represents the acceptable values for the DE-9IM.
The pattern matrix contains the acceptable values for each of the intersection matrix cells. The possible pattern values are:
TAn intersection must exist; dim = 0, 1,
or 2.
FAn intersection must not exist; dim = -1.
*It does not matter if an intersection exists or not; dim = -1, 0, 1, or
2.
0An intersection must exist and its maximum dimension must be 0; dim =
0.
1An intersection must exist and its maximum dimension must be 1; dim =
1.
2An intersection must exist and its maximum dimension must be 2; dim =
2.
Each predicate has at least one pattern matrix, but some require more than one to describe the relationships of various geometry type combinations.
The pattern matrix of the Within predicate for geometry combinations has the following form:
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
T |
* |
F |
|
a |
Boundary |
* |
* |
F |
|
|
Exterior |
* |
* |
* |
Simply put, the Within predicate returns true when the interiors of both geometries intersect, and the interior and boundary of a does not intersect the exterior of b. All other conditions do not matter.
Equal returns t (TRUE) if two geometries of the same type have identical X,Y coordinate values.
Geometries are equal if they have matching X,Y coordinates.
The DE-9IM
pattern matrix for equality ensures that the interiors intersect and that
no part
interior or boundary of either geometry intersects the exterior of the
other.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
T |
* |
F |
|
a |
Boundary |
* |
* |
F |
|
|
Exterior |
F |
F |
* |
Disjoint returns t (TRUE) if the intersection of the two geometries is an empty set.
Geometries are disjoint if they do not intersect one another in any way.
The disjoint predicates pattern matrix simply states that neither the interiors nor the boundaries of either geometry intersect.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
F |
F |
* |
|
a |
Boundary |
F |
F |
* |
|
|
Exterior |
* |
* |
* |
Intersects returns t (TRUE) if the intersection does not result in an empty set. Intersects returns the exact opposite result of disjoint.
The intersects predicate will return TRUE if the conditions of any of the following pattern matrices returns TRUE.
The intersects predicate returns TRUE if the interiors of both geometries intersect.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
T |
* |
* |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
* |
* |
* |
The intersects predicate returns TRUE if the boundary of the first geometry intersects the boundary of the second geometry.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
* |
T |
* |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
* |
* |
* |
The intersects predicate returns TRUE if the boundary of the first geometry intersects the interior of the second.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
* |
* |
* |
|
a |
Boundary |
T |
* |
* |
|
|
Exterior |
* |
* |
* |
The intersects predicate returns TRUE if the boundaries of either geometry intersect.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
* |
* |
* |
|
a |
Boundary |
* |
T |
* |
|
|
Exterior |
* |
* |
* |
Touch returns t (TRUE) if none of the points common to both geometries intersect the interiors of both geometries. At least one geometry must be a linestring, polygon, multilinestring, or multipolygon.
Touch returns TRUE if either of the geometries' boundaries intersect or if only one of the geometry's interiors intersects the other's boundary.
The pattern matrices show us that the touch predicate returns TRUE when the interiors of the geometry don't intersect and the boundary of either geometry intersects the others interior or boundary.
The touch predicate returns TRUE if the boundary of one geometry intersects the interior of the other but the interiors do not intersect.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
F |
T |
* |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
* |
* |
* |
The touch predicate returns TRUE if the boundary of one geometry intersects the interior of the other but the interiors do not intersect.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
F |
* |
* |
|
a |
Boundary |
T |
* |
* |
|
|
Exterior |
* |
* |
* |
The touch predicate returns TRUE if the boundaries of both geometries intersect but the interiors do not.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
F |
* |
* |
|
a |
Boundary |
* |
T |
* |
|
|
Exterior |
* |
* |
* |
Overlap compares two geometries of the same dimension and returns t (TRUE) if their intersection set results in a geometry different from both but of the same dimension.
Overlap returns t (TRUE) only for geometries of the same dimension and only when their intersection set results in a geometry of the same dimension. In other words, if the intersection of two polygons results in polygon, then overlap returns t (TRUE).
This pattern matrix applies to polygon/polygon, multipoint/multipoint and multipolygon/multipolygon overlays. For these combinations the overlap predicate returns TRUE if the interior of both geometries intersects the others interior and exterior.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
T |
* |
T |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
T |
* |
* |
This pattern matrix applies to linestring/linestring and multilinestring/multilinestring overlaps. In this case the intersection of the geometries must result in a geometry that has a dimension of 1 (another linestring). If the dimension of the intersection of the interiors had resulted in 0 (a point) the overlap predicate would return FALSE; however, the cross predicate would have returned TRUE.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
1 |
* |
T |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
T |
* |
* |
Cross returns t (TRUE) if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries. Cross returns t (TRUE) for only multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, and linestring/multipolygon comparisons.
Cross returns t (TRUE) if the dimension of the intersection is one less than the maximum dimension of the source geometries and the interiors of both geometries are intersected.
This cross predicate pattern matrix applies to multipoint/linestring, multipoint/multilinestring, multipoint/polygon, multipoint/multipolygon, linestring/polygon, and linestring/multipolygon. The matrix states that the interiors must intersect and that at least the interior of the primary (geometry a) must intersect the exterior of the secondary (geometry b).
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
T |
* |
T |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
* |
* |
* |
This cross predicate matrix applies to linestring/linestring, linestring/multilinestring, and multilinestring/multilinestring. The matrix states that the dimension of the intersection of the interiors must be 0 (intersect at a point). If the dimension of this intersection was 1 (intersect at a linestring) the cross predicate would return FALSE but the overlap predicate would return TRUE.
|
|
|
|
b |
|
|
|
|
Interior |
Boundary |
Exterior |
|
|
Interior |
0 |
* |
* |
|
a |
Boundary |
* |
* |
* |
|
|
Exterior |
* |
* |
* |
Within returns t (TRUE) if the first geometry is completely within the second geometry. Within tests for the exact opposite result of contains.
Within retu