geo:region-de9im( $region-1 as cts:region, $region-2 as cts:region, [$options as xs:string*] ) as xs:string
Calculates the Dimensionally Extended nine-Intersection Matrix (DE-9IM) of two geospatial regions.
This function calculates the Dimensionally Extended nine-Intersection Matrix (DE-9IM) of the two input regions, and returns the result as a string. In this model, a region divides the coordinate space into 3 sets of points: interior (I), boundary (B), and exterior (E). Each of these 3 sets from the first region is intersected with each of the 3 sets from the second region, and the dimensions of the intersections are calculated. This results in 9 dimensions, which are the entries of the matrix. These dimensions are also denoted using terms II, IB, IE, BI, etc. For instance, "IB" is the dimension of the intersection of the interior (I) of $region-1
with the boundary (B) of $region-2
.
The output of this function is a string of nine characters, which correspond to the 9 entries in the intersection matrix (in order): II, IB, IE, BI, BB, BE, EI, EB, EE. Each character will either be an integer "0", "1", or "2", representing the dimension of the intersection, or "F", indicating no intersection.
DE9-IM also defines spatial predicates based on the intersection matrix, including "intersects", "overlaps", and "contains". To test whether two regions satisfy one of these predicates, use geo:region-relate.
The value of the precision
option takes precedence over
that implied by the governing coordinate system name, including the
value of the coordinate-system
option. For example, if the
governing coordinate system is "wgs84/double" and the precision
option is "float", then the operation uses single precision.
let $r1 := cts:polygon("POLYGON((-122.427520751953 37.6555576956251,-122.459106445313 37.5658069549294,-122.289505004883 37.5946477878735,-122.427520751953 37.6555576956251))") let $r2 := cts:linestring("LINESTRING(-122.571029663086 37.5728821555562,-122.400054931641 37.6077041124284,-122.161102294922 37.5696167618573)") return geo:region-de9im($r1,$r2,("coordinate-system=wgs84","precision=double")) (: returns "1F20F1102", which reflects a "crosses" relationship :)