Or maybe just: plot(sp.usa[3]) class(sp.usa[3]) [1] "SpatialPolygons" attr(,"package") [1] "sp"
On 06/22/2010 10:59 PM, Hans-Jörg Bibiko wrote: > > 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 -- Edzer Pebesma Institute for Geoinformatics (ifgi), University of Münster Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251 8333081, Fax: +49 251 8339763 http://ifgi.uni-muenster.de http://www.52north.org/geostatistics e.pebe...@wwu.de _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo