maptools (version 0.7-22)

subset.polylist: Subset polygon list objects

Description

The function subsets a polygon list object, also subsetting region ID attributes and also map limits if required.

Usage

## S3 method for class 'polylist':
subset(x, subset, fit.bbox = TRUE, ...)

Arguments

x
a polylist object
subset
a logical vector valued TRUE if the element is to be retained
fit.bbox
if TRUE (default) modifies the maplim attribute to bound the subset
...
other arguments passed through

Value

  • returns a polylist object, lists of polygon boundary coordinates (divided by NA where the polygon object is represented by more than one polygon);

Examples

Run this code
nc <- read.shape(system.file("shapes/sids.shp", package = "maptools")[1])
mappolys <- Map2poly(nc, as.character(nc$att.data$FIPSNO))
submap <- subset(mappolys, nc$att.data$SID74 > 0)
plot(mappolys, col="orange")
plot(submap, add=TRUE, col="lightpink", forcefill=TRUE)

Run the code above in your browser using DataCamp Workspace