The Dimensionally Extended 9 Intersection Model

The Dimensionally Extended 9 Intersection Model (DE-9IM) developed by Clementini and others, 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) produce 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().
Table 1. Results of intersections

The table is a 3-by-3 matrix.

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 for the functions can be understood or verified by comparing the results 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. For example, the pattern matrix of the ST_Within() function for geometry combinations has the following form:
Table 2. Pattern matrix of the ST_Within() function
b
Interior Boundary Exterior
Interior T * F
a Boundary * * F
Exterior * * *

Simply put, the ST_Within() function returns TRUE when the interiors of both geometries intersect, and the interior and boundary of geometry a does not intersect the exterior of geometry b. All other conditions do not matter.