Monday, August 1, 2011

extract maps in sp format from the maps package in R

from the doc of the package spacetime :

library(maps)
states.m = map('state', plot=FALSE, fill=TRUE)
IDs <- sapply(strsplit(states.m$names, ":"), function(x) x[1])
library(maptools)
states = map2SpatialPolygons(states.m, IDs=IDs)
class(states)
[1] "SpatialPolygons"
attr(,"package")
[1] "sp"

No comments:

Post a Comment