gRelate

0th

Percentile

Geometry Relationships - Intersection Matrix Pattern (DE-9IM)

Determines the relationships between two geometries by comparing the intersection of Interior, Boundary and Exterior of both geometries to each other. The results are summarized by the Dimensionally Extended 9-Intersection Matrix or DE-9IM.

Keywords
spatial
Usage
gRelate(spgeom1, spgeom2 = NULL, pattern = NULL, byid = FALSE)
Arguments
spgeom1, spgeom2
sp objects as defined in package sp. If spgeom2 is NULL then spgeom1 is compared to itself.
byid
Logical vector determining if the function should be applied across ids (TRUE) or the entire object (FALSE) for spgeom1 and spgeom2
pattern
Character string containing intersection matrix pattern to match against DE-9IM for given geometries. Wild card * or * characters allowed.
Details

Each geometry is decomposed into an interior, a boundary, and an exterior region, all the resulting geometries are then tested by intersection against one another resulting in 9 total comparisons. These comparisons are summarized by the dimensions of the intersection region, as such intersection at point(s) is labeled 0, at linestring(s) is labeled 1, at polygons(s) is labeled 2, and if they do not intersect labeled F.

If a pattern is specified then limited matching with wildcards is possible, * matches any character whereas T matches any non-F character.

Value

• By default returns a 9 character string that represents the DE-9IM.

If pattern returns TRUE if the pattern matches the DE-9IM.

References

Documentation of Intersection Matrix Patterns: http://docs.codehaus.org/display/GEOTDOC/Point+Set+Theory+and+the+DE-9IM+Matrix#PointSetTheoryandtheDE-9IMMatrix-9IntersectionMatrix

gContains gContainsProperly gCovers gCoveredBy gCrosses gDisjoint gEquals gEqualsExact gIntersects gOverlaps gTouches gWithin

• gRelate
• RGEOSRelate
Examples
x = readWKT("POLYGON((1 0,0 1,1 2,2 1,1 0))")
x.inter = x
x.bound = gBoundary(x)

y = readWKT("POLYGON((2 0,1 1,2 2,3 1,2 0))")
y.inter = y
y.bound = gBoundary(y)

xy.inter = gIntersection(x,y)
xy.inter.bound = gBoundary(xy.inter)

xy.union = gUnion(x,y)
bbox = gBuffer(gEnvelope(xy.union),width=0.5,joinStyle='mitre',mitreLimit=3)

x.exter = gDifference(bbox,x)
y.exter = gDifference(bbox,y)

# geometry decomposition
par(mfrow=c(2,3))

defaultplot = function() {
plot(bbox,border='grey')
}

# Dimensionally Extended 9-Intersection Matrix
pat = gRelate(x,y)
patchars = strsplit(pat,"")[[1]]

par(mfrow=c(3,3))
title(paste("dim:",patchars[1]))
title(paste("dim:",patchars[2]))
title(paste("dim:",patchars[3]))

title(paste("dim:",patchars[4]))
title(paste("dim:",patchars[5]))
title(paste("dim:",patchars[9]))