Spatial Relations Defined
Spatial relationships are described by predicates - keywords that indicate the type of relationship each piece of geometry has with another. These relationships are defined by the OGC (Open Geospatial Consortium), and are interpreted in FME.
Spatial relationships are based on how three components of a feature intersect - or don't intersect - with another feature. Each feature has an INTERIOR, BOUNDARY, and EXTERIOR. These terms are defined below for various geometry types. How these components interact determines the type of spatial relationship features have, and which predicates they match.
BOUNDARY | Point | Empty set. |
Line |
CURVE_BOUNDARY_RULE ENDPOINTS_MOD2 The boundary is the set of all endpoints that occur an odd number of times. For a simple linear feature (that is, not a multicurve), this means the boundary is comprised of the start and end points, unless the line is closed (the start and end are the same point), in which case the boundary is the empty set. (This is the default if CURVE_BOUNDARY_RULE is unspecified.) CURVE_BOUNDARY_RULE ENDPOINTS_ALL The boundary is the set of all endpoints, regardless of the number of times they occur in the geometry. |
|
Area | The border of a polygon, including the border of the holes. | |
INTERIOR | Point | The point location. |
Line | The entire line except its boundary as determined above. | |
Area | The inner surface of the polygon. | |
EXTERIOR | Point | Everything that is not on the BOUNDARY or the INTERIOR. |
Line | ||
Area |
Spatial relations are undefined for inputs that are not OGC valid geometries or aggregates of OGC valid geometries. For definitive documentation on spatial relations, please consult the OGC documentation. For more information on how FME handles aggregate and multi geometries, which differs from OGC’s documentation, see below.
Spatial Predicates
Predicates - such as OGC-Intersects, OGC-Contains, OGC-Overlaps, and more - are commonly used in spatial joins. The SpatialFilter and SpatialRelator allow explicit spatial query construction using predicates.
Each of the supported predicates is described here, along with some associated examples and pattern matrices. Note that the examples are not exhaustive: there may be entirely different situations where a given predicate is true.
Spatial Predicates with Examples
In these examples, the base is labeled "A" and the candidate is labeled "B".
Geometry examples are shown comparing points, lines, and areas. Bases are in blue, candidates in yellow. Examples showing multiple bases or candidates do not represent multi or aggregate geometry, rather, they indicate alternate scenarios that match the predicate.
Predicate |
Description |
Geometry Examples |
Pattern Matrix* |
---|---|---|---|
OGC-Intersects | The two features are not OGC-Disjoint, as defined next. | ||
OGC-Disjoint
|
The boundary and interior of each feature do not intersect the boundary or interior of the other. | ||
OGC-Equals
|
The features have the same boundary and the same interior. | ||
OGC-Touches
|
The interiors do not intersect, but either the boundaries intersect or one boundary intersects the other interior. |
||
OGC-Crosses
|
The base has a lower dimensionality than the candidate and its interior intersects the candidates interior and exterior. Alternatively, both inputs are lines and their interiors only intersect at points.
|
||
For two lines: |
|||
OGC-Overlaps
|
The interiors intersect, but neither feature is contained by the other, nor are the features equal. Undefined for point/line, point/area, or line/area. Undefined for aggregate/multi geometries. |
||
For two lines: | |||
OGC-Contains
|
The interiors intersect and no part of the candidate's interior or boundary intersects the base's exterior. The candidate’s interior or boundary may intersect the base’s boundary. Inverse of WITHIN. |
||
OGC-Within
|
The interiors intersect and no part of the base's interior or boundary intersects the candidate's exterior. The base’s interior or boundary may intersect the candidate’s boundary. Inverse of CONTAINS. |
* See Dimensionally Extended 9 Intersection Matrix (DE-9IM) below.
Aggregates and Multi Geometry
Spatial relationships for aggregate and multi geometries are not clearly defined, and should be used with care.
OGC has definitions for valid MultiPoints, MultiCurves, MultiSurfaces, and how they interact with spatial relationships, but FME does not currently adopt these definitions. Instead, simple extensions are provided for aggregates of OGC valid geometries, as described below.
All relationships are defined for all combinations of multi-geometry types, with the exception of IFMEMultiText, IFMEMultiSurface, and IFMEMultiSolid, which are not defined for any relationship. Any places where a relationship differs from this rule are noted.
OGC-Intersects |
A geometry intersects a multi if, and only if, at least one part of the multi intersects the geometry. The same is true for a multi intersecting a geometry. A multi intersects another multi if, and only if, at least one part from one multi intersects at least one part of the other multi. |
OGC-Disjoint |
A geometry is disjoint from a multi if, and only if, the geometry is disjoint from all parts of the multi. The same is true for a multi being disjoint from a geometry. A multi is disjoint from another multi if, and only if, all parts from each multi are disjoint from all points of the other multi. |
OGC-Equals |
A multi can only be equal to another multi of the same type (for example, IFMEAggregate with IFMEAggregate, or IFMEMultiCurve with IFMEMultiCurve). Two multis are equal if, and only if, the number of parts in each multi is the same, and each part from one multi has an equal match in the other multi, with no ‘double matches’ (that is, no part of either multi can be left without a match). |
OGC-Touches |
A geometry touches a multi if, and only if, at least one part of the multi touches the geometry, and no other non-touching parts intersect with the geometry. The same is true for a multi touching a geometry. A multi touches another multi if, and only if, at least one part of each multi touches a part of the other, and no non-touching parts intersect parts of the other. |
OGC-Crosses |
Is not supported for multi/aggregate geometries. |
OGC-Overlaps |
Is not supported for multi/aggregate geometries. |
OGC-Contains |
A geometry contains a multi if, and only if, the geometry contains all parts of the multi. A multi contains a geometry if, and only if, at least one part of the multi contains the geometry. A multi contains another multi if, and only if, at least one part of the container multi contains all parts of the containee. |
OGC-Within |
A geometry is within a multi if, and only if, the geometry is within at least one part of the multi. A multi is within a geometry if, and only if, every part of the multi is within the geometry. A multi is within another multi if, and only if, every part of the contained multi is within at least one part of the container multi. |
Transformer Terminology
Spatial predicate descriptions vary according to context. The following terms are equivalent to Base and Candidate as used here.
Transformer |
Base |
Candidate |
---|---|---|
SpatialFilter | Filter | Candidate |
SpatialRelator | Requestor | Supplier |
Dimensionally Extended 9 Intersection Matrix (DE-9IM)
The comparison of two features produces a 3 x 3 matrix known as the Dimensionally Extended 9 Intersection Matrix (DE-9IM). These matrices may also be represented as a 9-character string.
Matrix examples are included in the Predicates table above.
Candidate | ||||
Interior | Boundary | Exterior | ||
Base | Interior | x0 | x1 | x2 |
Boundary | x3 | x4 | x5 | |
Exterior | x6 | x7 | x8 |
The value of each element of the matrix indicates the dimension of the geometry produced by intersecting the given parts of the two features. The dimension is one of the following:
Dimension |
Description |
---|---|
-1 | There is no interaction |
0 | Intersection produces a point |
1 | Intersection produces a line |
2 | Intersection produces a surface |
So for instance, if x1 is 1, then the intersection of the base's interior with the candidate's boundary produces a line. This could occur when both features are polygons and they overlap.
Each of the predicates can be defined in terms of what the intersection matrix of the two features must look like. For this, use a pattern matrix. Each element of the pattern matrix can be one of the following:
Value |
Description |
---|---|
* | The value of this element may be anything (-1, 0, 1, or 2) |
T | The value of this element must be 0, 1, or 2 (point, line, or surface) |
F | The value of this element must be -1 (no interaction) |
0 | The value of this element must be 0 (point) |
1 | The value of this element must be 1 (line) |
2 | The value of this element must be 2 (surface) |
The pattern matrix for the disjoint predicate is:
This means that neither feature's interior or boundary may interact with the other's interior or boundary.
More examples may be seen in the Examples table above.
String Representations of Intersection Matrices
Any intersection matrix can be represented as a 9-character string. To generate the string representation of a particular intersection matrix, take each element starting from the top-left, going left-to-right for each row.
For example, the string representation of the intersection matrix for the disjoint predicate (as seen above) is “FF*FF****”.