The
DE-9IM offers a full descriptive assertion about the two input geometries. It is a mathematical function that represents a
complete set of all possible relations about two entities, like a
Truth table, the
Three-way comparison, a
Karnaugh map or a
Venn diagram. Each output value is like a truth table line, that represent relations of specific inputs. As illustrated above, the output '212101212' resulted from
DE-9IM(
a,
b) is a complete description of all topologic relations between specific geometries
a and
b. It says to us that . By other hand, if we check predicates like
Intersects(
a,
b) or
Touches(
a,
b) — for the same example we have "
Intersects= and
Touches=" — it is an incomplete description of "all topologic relations". Predicates also do not say any thing about the dimensionality of the geometries (it doesn't matter if
a and
b are lines, areas or points). This independence of geometry-type and the lack of
completeness, on
predicates, are useful for
general queries about two geometries: : For usual applications, the use of
spatial predicates also is justified by being more
human-readable than
DE-9IM descriptions: a typical user have better intuition about predicates (than a set of interiors/border/exterior intersections). Predicates have useful
semantic into usual applications, so it is useful the translation of a
DE-9IM description into a list of all associated predicates, that is like a
casting process between the two different semantic types. Examples: • The string codes "" and "" have the semantic of "
Intersects & Crosses & Overlaps". • The string code "" have the semantic of "
Equals". • The string codes "", "", "", "", and "" have the semantic of "
Intersects & Touches".
Standards The
Open Geospatial Consortium (OGC) has standardized the typical spatial predicates (Contains, Crosses, Intersects, Touches, etc.) as boolean functions, and the DE-9IM model, as a function that returns a string (the DE-9IM code), with domain of , meaning =point, =line, =area, and ="empty set". This DE-9IM string code is a standardized format for data interchange. The
Simple Feature Access (ISO 19125) standard, in the chapter 7.2.8, "SQL routines on type Geometry", recommends as supported routines the
SQL/MM Spatial (ISO 13249-3 Part 3: Spatial)
ST_Dimension,
ST_GeometryType,
ST_IsEmpty,
ST_IsSimple,
ST_Boundary for all Geometry Types. The same standard, consistent with the definitions of relations in "Part 1, Clause 6.1.2.3" of the SQL/MM, recommends (shall be supported) the function labels:
ST_Equals,
ST_Disjoint,
ST_Intersects,
ST_Touches,
ST_Crosses,
ST_Within,
ST_Contains,
ST_Overlaps and
ST_Relate. The DE-9IM in the OGC standards use the following definitions of Interior and Boundary, for the main OGC standard geometry types:
Implementation and practical use Most spatial databases, such as
PostGIS, implements the
DE-9IM() model by the standard functions: ST_Relate, ST_Equals, ST_Intersects, etc. The function ST_Relate(a,b) outputs the standard OGC's
DE-9IM string code. Examples: two geometries,
a and
b, that intersects and touches with a point (for instance with and ), can be ST_Relate(a,b)='FF1F0F1F2' or ST_Relate(a,b)='FF10F0102' or ST_Relate(a,b)='FF1F0F1F2'. It also satisfies ST_Intersects(a,b)=true and ST_Touches(a,b)=true. When ST_Relate(a,b)='0FFFFF212', the returned DE-9IM code have the semantic of "Intersects(a,b) & Crosses(a,b) & Within(a,b) & CoveredBy(a,b)", that is, returns true on the boolean expression ST_Intersects(a,b) AND ST_Crosses(a,b) AND ST_Within(a,b) AND ST_Coveredby(a,b). The use of is faster than direct computing of a set of correspondent predicates. There are cases where using is the only way to compute a complex predicate — see the example of the code 0FFFFF0F2, of a point that not "crosses" a multipoint (an object that is a set of points), but predicate
Crosses (when defined by a mask) returns
true. It is usual to
overload the by adding a mask parameter, or use a returned string into the function. When using , it returns a boolean. Examples: • ST_Relate(a,b,'*FF*FF212') returns
true when ST_Relate(a,b) is 0FFFFF212 or 01FFFF212, and returns
false when 01FFFF122 or 0FF1FFFFF. • ST_RelateMatch('0FFFFF212','*FF*FF212') and ST_RelateMatch('01FFFF212','TTF*FF212') are
true, ST_RelateMatch('01FFFF122','*FF*FF212') is
false. == Synonyms ==