readSplus: Read exported WinBUGS maps

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/readSplus.R

Description

The function permits an exported WinBUGS map to be read into an sp package class SpatialPolygons object.

Usage

1
readSplus(file, proj4string = CRS(as.character(NA)))

Arguments

file

name of file

proj4string

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

Value

readSplus returns a SpatialPolygons object

Note

In the example, taken from the GeoBUGS manual, the smaller part of area1 has a counter-clockwise ring direction in the data, while other rings are clockwise. This implies that it is a hole, and does not get filled. Errant holes may be filled using checkPolygonsHoles. The region labels are stored in the ID slots of the Polygons objects.

Author(s)

Virgilio Gomez Rubio <Virgilio.Gomez@uclm.es>

References

http://www.mrc-bsu.cam.ac.uk/wp-content/uploads/geobugs12manual.pdf

See Also

map2SpatialPolygons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
if (rgeosStatus()) {
geobugs <- readSplus(system.file("share/Splus.map", package="maptools"))
plot(geobugs, axes=TRUE, col=1:3)
row.names(geobugs)
pls <- slot(geobugs, "polygons")
sapply(pls, function(i) sapply(slot(i, "Polygons"), slot, "hole"))
pls1 <- lapply(pls, checkPolygonsHoles)
sapply(pls1, function(i) sapply(slot(i, "Polygons"), slot, "hole"))
plot(SpatialPolygons(pls1), axes=TRUE, col=1:3)
}

Example output

Loading required package: sp
Checking rgeos availability: FALSE
 	Note: when rgeos is not available, polygon geometry 	computations in maptools depend on gpclib,
 	which has a restricted licence. It is disabled by default;
 	to enable gpclib, type gpclibPermit()

maptools documentation built on Sept. 7, 2021, 5:09 p.m.