[R-sig-Geo] how to transform Polygons to SpatialPolygons
Weidong Gu
wgu at uab.edu
Tue Jun 22 22:29:39 CEST 2010
Hi,
I ran into a problem in subsetting the Mainland from a usa map
Library(maps)
usa=map('usa',plot=F,fill=T)
IDs=sapply(strsplit(state$names,':'), function(x) x[1])
crs=CRS('+proj=longlat +ellps=WGS84')
sp.usa=map2SpatialPolygons(usa,IDs=usa$names,proj4string=crs)
since sp.usa consists of a group of lands and I only need the mainland, then
mainland=slot(sp.usa,'polygons')[[3]]
class(mainland)
[1] "Polygons"
attr(,"package")
[1] "sp"
The question is how to transform 'mainland' back into SpatialPolygons format.
Any advice would be appreciated.
Weidong Gu,
University of Alabama, Birmingham
More information about the R-sig-Geo
mailing list