Learn R Programming

surveillance (version 1.7-0)

polyAtBorder: Indicate Polygons at the Border

Description

Determines which polygons of a "SpatialPolygons" object are at the border, i.e. have coordinates in common with the spatial union of all polygons (constructed using unionSpatialPolygons).

Usage

polyAtBorder(SpP, snap = sqrt(.Machine$double.eps),
             method = "rgeos", ...)

Arguments

SpP
an object of class "SpatialPolygons".
snap
tolerance used to consider coordinates as identical.
method
method to use for unionSpatialPolygons. Defaults to "rgeos", since polyclip uses integer arithmetic, which causes rounding errors usually requiring tuning of
...
further arguments passed to the chosen method.

Value

  • logical vector of the same length as SpP also inheriting its row.names.

Examples

Run this code
## Load districts of Germany
load(system.file("shapes", "districtsD.RData", package="surveillance"))

## indicate districts at the border
districtAtBorder <- polyAtBorder(districtsD)

## plot to check
plot(districtsD, col=districtAtBorder)

## polyclip cannot be used with the default snapping tolerance
plot(districtsD, col=polyAtBorder(districtsD, method="polyclip"))
## but increasing the tolerance gives the correct result
stopifnot(identical(districtAtBorder,
                    polyAtBorder(districtsD, snap=1e-6, method="polyclip")))

Run the code above in your browser using DataLab