Home    |    Concepts   |   API   |   Samples
Concepts > Geometry > Shapes > Spatial Relations
Predicates

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().

  Interior Boundary Exterior
Interior dim(I(a)∩(b)) dim(I(a)∩(b)) dim(I(a)∩(b))
Boundary dim(B(a)∩(b)) dim(B(a)∩(b)) dim(B(a)∩(b))
Exterior 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:

   

b

    Interior Boundary Exterior
a Interior T * F
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.

feedback | privacy | legal