Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pal2SpatialPolygons

Making SpatialPolygons objects from RArcInfo input


Description

This function is used in making SpatialPolygons objects from RArcInfo input.

Usage

pal2SpatialPolygons(arc, pal, IDs, dropPoly1=TRUE,
 proj4string=CRS(as.character(NA)))

Arguments

IDs

Unique character ID values for each output Polygons object; the input IDs can be an integer or character vector with duplicates, where the duplicates will be combined as a single output Polygons object

proj4string

Object of class "CRS"; holding a valid proj4 string

arc

Object returned by get.arcdata

pal

Object returned by get.paldata

dropPoly1

Should the first polygon in the AVC or e00 data be dropped; the first polygon is typically the compound boundary of the whole dataset, and can be detected by looking at the relative lengths of the list components in the second component of pal, which are the numbers of arcs making up the boundary of each polygon

Value

The functions return a SpatialPolygons object

Author(s)

Roger Bivand

Examples

nc1 <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], ID="FIPS")
plot(nc1)
text(coordinates(nc1), labels=row.names(nc1), cex=0.6)
if(require(maps)){
ncmap <- map("county", "north carolina", fill=TRUE, col="transparent",
 plot=FALSE)
IDs <- sapply(strsplit(ncmap$names, "[,:]"), function(x) x[2])
nc2 <- map2SpatialPolygons(ncmap, IDs)
plot(nc2)
text(coordinates(nc2), labels=row.names(nc2), cex=0.6)
}
#if(require(RArcInfo)) {
#td <- tempdir()
#tmpcover <- paste(td, "nc", sep="/")
#if (!file.exists(tmpcover)) e00toavc(system.file("share/co37_d90.e00",
# package="maptools")[1], tmpcover)
#arc <- get.arcdata(td, "nc")
#pal <- get.paldata(td, "nc")
#pat <- get.tabledata(paste(td, "info", sep="/"), "NC.PAT")
#sapply(pal[[2]], function(x) length(x[[1]]))
#IDs <- paste(pat$ST[-1], pat$CO[-1], sep="")
#nc3 <- pal2SpatialPolygons(arc, pal, IDs=IDs)
#plot(nc3)
#text(coordinates(nc3), labels=row.names(nc3), cex=0.6)
#}

maptools

Tools for Handling Spatial Objects

v1.1-1
GPL (>= 2)
Authors
Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>), Nicholas Lewin-Koh [aut], Edzer Pebesma [ctb], Eric Archer [ctb], Adrian Baddeley [ctb], Nick Bearman [ctb], Hans-Jörg Bibiko [ctb], Steven Brey [ctb], Jonathan Callahan [ctb], German Carrillo [ctb], Stéphane Dray [ctb], David Forrest [ctb], Michael Friendly [ctb], Patrick Giraudoux [ctb], Duncan Golicher [ctb], Virgilio Gómez Rubio [ctb], Patrick Hausmann [ctb], Karl Ove Hufthammer [ctb], Thomas Jagger [ctb], Kent Johnson [ctb], Matthew Lewis [ctb] (<https://orcid.org/0000-0003-2244-4078>), Sebastian Luque [ctb], Don MacQueen [ctb], Andrew Niccolai [ctb], Edzer Pebesma [ctb], Oscar Perpiñán Lamigueiro [ctb], Ethan Plunkett [ctb], Ege Rubak [ctb] (<https://orcid.org/0000-0002-6675-533X>), Tom Short [ctb], Greg Snow [ctb], Ben Stabler [ctb], Murray Stokely [ctb], Rolf Turner [ctb]
Initial release
2021-03-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.