subGeom: Extract a sub-polygon or coordinates thereof from a...

Description Usage Arguments Value See Also Examples

View source: R/subGeom.r

Description

This function extracts a sub-polygon or the coordinates of vertices a sub-polygon from a SpatialPolygon or SpatialPolygonDataFrame object.

Usage

1
subGeom(x, n)

Arguments

x

SpatialPolygon or SpatialPolygonDataFrame.

n

Positive integer(s) indicating which sub-polygon(s) to obtain. To see the number of sub-polygons in an object use countSubGeoms. If NULL, then the function basically returns x, but with all sub-geometries split (i.e., a multi-part polygon/lines).

out

Character, either 'poly' (default) or 'coords', indicating the returned object should either be a spatial polygon or a matrix of coordinates.

Value

A spatial polygon object or a two-column matrix.

See Also

countSubGeoms, geomToCoords

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(mad0)
sub <- subGeom(mad0, 1)
pts <- geomToCoords(mad0, 1)
plot(sub)
points(pts)

N <- countSubGeoms(mad0)
sub <- subGeom(mad0, N)
plot(sub)

par(mfrow=c(4, 4))
for (n in 1:16) {
sub <- subGeom(mad0, n)
plot(sub)
}

adamlilith/birdsEye documentation built on May 23, 2020, 4:40 p.m.