I see previous postings suggest
a for loop should work, but I'm not able to extract the individual polygons.
I post the following portion since I can get to this point in my
script....but the extraction step fails (most likely due to my inability to
specify what part of the SpatialPolygonsDataFrame to extract.....
library(sp)
library(maptools)
library(splancs)
library(rgdal)
library(spdep)
nc.sids<- readShapePoly(system.file("etc/shapes/sids.shp",
package="spdep")[1],
ID="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))
rn<- sapply(slot(nc.sids, "polygons"), function(x) slot(x, "ID"))
for (i in 1:length(rn)) {
temp.poly= ---- effectively, rn[i], i.e. a polygon with ID=="i". I can then
assign data from the result of the pip function, but I'm having difficulty
extracting each polygon sequentially to do this.
Any help is much appreciated!
Thanks!