On Jun 22, 2010, at 10:29 PM, Weidong Gu wrote: > > The question is how to transform 'mainland' back into SpatialPolygons format.
Hi, maybe try the following: library(maps) library(maptools) usa=map('usa',plot=F,fill=T) IDs=sapply(strsplit(usa$names,':'), function(x) x[1]) crs=CRS('+proj=longlat +ellps=WGS84') sp.usa=map2SpatialPolygons(usa,IDs=usa$names,proj4string=crs) mainland <- list(slot(sp.usa,'polygons')[[3]]) sp_mainland <- SpatialPolygons(mainland, proj4string=crs) str(sp_mainland) plot(sp_mainland) Cheers, --Hans ********************************************************** Hans-Joerg Bibiko Max Planck Institute for Evolutionary Anthropology Department of Linguistics Deutscher Platz 6 phone: +49 (0) 341 3550 341 D-04103 Leipzig fax: +49 (0) 341 3550 333 Germany e-mail: bibiko[-at-]eva.mpg.de _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo