Dear list, I'd like to loop through all polygons in a shapefile, and count
the # of points of interest in each polygon. 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!

-- 
David Depew
Postdoctoral Fellow
School of Environmental Studies
Queen's University
Kingston, Ontario
K7L 3N6

david.depew@queensu.ca
P: (613) 533-6000 x77831

	[[alternative HTML version deleted]]

