Predicates are Boolean functions that return TRUE (t) if a comparison meets the
functions criteria; otherwise, they return FALSE (f), to determine if a specific
relationship exists between a pair of geometries.
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 do not.
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.
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().
|
dim(I(a)∩(b)) |
dim(I(a)∩(b)) |
dim(I(a)∩(b)) |
dim(B(a)∩(b)) |
dim(B(a)∩(b)) |
dim(B(a)∩(b)) |
dim(E(a)∩(b)) |
dim(E(a)∩(b)) |
dim(E(a)∩(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
T An intersection must exist; dim = 0, 1, or 2.
F An intersection must not exist; dim = -1.
* It does not matter if an intersection exists or not; dim = -1, 0, 1, or
2.
0 An intersection must exist and its maximum dimension must be 0; dim =
0.
1 An intersection must exist and its maximum dimension must be 1; dim =
1.
2 An 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:
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 TRUE if two geometries of the same type have identical x,y coordinate values, i.e. if the secondary shape is equal (identical) to the primary shape
object. This applies to all shape type combinations. Two shapes are equal if they have:
- The same coordinate reference system
- The same type
- The same number of points
- The identical points in the same order (x, y, z, and measures)
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.
C API Function: SE_shape_is_equal (link to API func)
Java API Class/Method: SeShape.isEqual(SeShape secondaryShape) (API LINK)
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.
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.
The intersects predicate returns TRUE if the boundary of the first geometry
intersects the boundary of the second geometry.
The intersects predicate returns TRUE if the boundary of the first geometry
intersects the interior of the second.
The intersects predicate returns TRUE if the boundaries of either geometry
intersect.
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.
The touch predicate returns TRUE if the boundary of one geometry intersects
the interior of the other but the interiors do not intersect.
The touch predicate returns TRUE if the boundaries of both geometries
intersect but the interiors do not.
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.
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.
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).
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.
Within returns t (TRUE) if the first geometry is completely within the second
geometry. Within tests for the exact opposite result of contains.
Within returns t (TRUE) if the first geometry is completely inside the second
geometry. The boundary and interior of the first geometry are not allowed to
intersect the exterior of the second geometry and the first geometry may not
equal the second geometry.
The within predicate pattern matrix states that the interiors of both geometries
must intersect and that the interior and boundary of the primary geometry
(geometry a) must not intersect the exterior of the secondary (geometry b).
Contains returns t (TRUE) if the second geometry is completely contained by the
first geometry. The contains predicate returns the exact opposite result of the
within predicate.
Contains returns t (TRUE) if the second geometry is completely inside the first.
The boundary and interior of the second geometry are not allowed to intersect
the exterior of the first geometry and the geometries may not be equal.
The pattern matrix of the contains predicate states that the interiors of both
geometries must intersect and that the interior and boundary of the secondary
(geometry b) must not intersect the exterior of the primary (geometry a).
|