gIntersection {rgeos}R Documentation

Geometry Intersections

Description

Function for determining the intersection between the two given geometries

Usage

gIntersection(spgeom1, spgeom2, byid=FALSE, id=NULL)

Arguments

spgeom1, spgeom2

sp objects as defined in package sp

byid

Logical vector determining if the function should be applied across ids (TRUE) or the entire object (FALSE) for spgeom1 and spgeom2

id

Character vector defining id labels for the resulting geometries, if unspecified returned geometries will be labeled based on their parent geometries' labels.

Details

Returns all spatial intersections as sp objects of the appropriate class. If the geometries do not intersect then an empty geometry is returned.

Author(s)

Roger Bivand & Colin Rundel

See Also

gDifference gSymdifference gUnion

Examples

library(maptools)
xx <- readShapeSpatial(system.file("shapes/fylk-val-ll.shp", package="maptools")[1], proj4string=CRS("+proj=longlat +datum=WGS84"))
bbxx <- bbox(xx)
wdb_lines <- system.file("share/wdb_borders_c.b", package="maptools")
xxx <- Rgshhs(wdb_lines, xlim=bbxx[1,], ylim=bbxx[2,])$SP
res <-gIntersection(xx, xxx)
plot(xx, axes=TRUE)
plot(xxx, lty=2, add=TRUE)
plot(res, add=TRUE, pch=16,col='red')

[Package rgeos version 0.2-2 Index]