Dear list,

I have imported a shp file with:

> pols <- readOGR("../AllTransectPolygons02", 
layer="AllTransectPolygons02")

> class(pols)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"

> [EMAIL PROTECTED]
     AREA PERIMETER               Site
0   2500      1010           Lupuna 1
1   2500      1010           Lupuna 3
2   2500      1010           Lupuna 2
3   2500      1010             Aleman
4   2500      1010        Zancudoyacu
etc

and now I want to select few polygons according
to a vector of Site names.

Thinking on how doing this, I thought I could select
the corresponding IDs in the data table and then use
the ID slot in the polygons, but
I've found that the polygons themselves actually
lack the ID information:

> getPolygonsIDSlot(pols)
Error in getPolygonsIDSlot(pols) :
   no slot of name "ID" for this object of class "SpatialPolygonsDataFrame"

How does sp relate the data table to the polygons if there is no ID?

In any case, which would the most efficient way of subseting
the SpatialPolygonsDataFrame into another SpatialPolygonsDataFrame
with the selected polygons? Should I convert to a maptools object
and use subset.polylist()? If so, how do I convert? I've tried:

pols.maptools <- SpatialPolygons2PolySet(pols)

but the data table is lost.

Thanks!

-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster


-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra "Jaume Almera" (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to