Learn R Programming

eeptools (version 1.2.4)

mapmerge: A depcrecated method for converting polygons to dataframes Combine an S4 polygon object with a dataframe

Description

Convenience function for merging dataframes and S4 spatial polygon objects.

Usage

mapmerge(mapobj, data, xid, yid)

Value

A SpatialPolygonsDataFrame with new variables attached from supplied dataframe

Arguments

mapobj

Name of an S4 SpatialPolygonsDataFrame

data

Name of a dataframe

xid

Name of ID variable in the SpatialPolygonsDataFrame

yid

Name of ID variable in the dataframe

Examples

Run this code
if (FALSE) {
xx <- maptools::readShapePoly(system.file("shapes/sids.shp", package="maptools")[1], IDvar="FIPSNO")
yy <- as(xx,"data.frame")
yy$newvar <- sample(letters, nrow(yy), replace=TRUE)
yy <- subset(yy, select=c("FIPS", "newvar"))
newpoly <- mapmerge(xx, yy, xid="FIPS", yid="FIPS")
}

Run the code above in your browser using DataLab