# Function that compares two geometries with the DE-9IM pattern matrix string

The ST_Relate function compares two geometries and returns a value of 1 if the geometries meet the conditions specified by the DE-9IM pattern matrix string; otherwise, the function returns a value of 0.

The Dimensionally Extended 9 Intersection Model (DE-9IM) is a mathematical model that defines the pair-wise spatial relationship between geometries of different types and dimensions. This model expresses spatial relationships between all types of geometries as pair-wise intersections of their interiors, boundaries, and exteriors, with consideration for the dimension of the resulting intersections.

*a*and

*b*:

- I(
*a*), B(*a*), and E(*a*) represent the interior, boundary, and exterior of*a*. - I(
*b*), B(*b*), and E(*b*) represent the interior, boundary, and exterior of*b*.

*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 consists of a point and a linestring, in which case the

**dim**function returns the maximum dimension of 1.

The **dim** function returns a value of -1, 0, 1 or 2. The -1 corresponds to the null set or
dim(null), which is returned when no intersection was found.

Results returned by comparison functions can be understood or verified by comparing the results returned by a comparison function with a pattern matrix that represents the acceptable values for the DE-9IM.

- 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; dim = -1, 0, 1, or 2.
- 0
- An intersection must exist and its exact 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 function has at least one pattern matrix, but some require more than one to describe the relationships of various geometry type combinations.

The DE-9IM was developed by Clementini and Felice, who dimensionally extended the 9 Intersection
Model of Egenhofer and Herring. The DE-9IM is a collaboration of four authors (Clementini, Eliseo,
Di Felice, and van Osstrom) who published the model in A Small Set of Formal Topological
Relationships Suitable for End-User Interaction

, D. Abel and B.C. Ooi (Ed.), *Advances in
Spatial Database-Third International Symposium. SSD '93*. LNCS 692. Pp. 277-295. The 9
Intersection model by M. J. Egenhofer and J. Herring (Springer-Verlag Singapore [1993]) was
published in Categorizing binary topological relationships between regions, lines, and points in
geographic databases

, *Tech. Report, Department of Surveying Engineering*, University of
Maine, Orono, ME 1991.