[R-sig-Geo] extracting polygons
Agustin Lobo
Agustin.Lobo at ija.csic.es
Tue Apr 8 15:01:50 CEST 2008
Dear list,
I want to distribute a set of N circles according to a random distribution
within a set of polygons (N circles within each polygon).
I have an object of class SpatialPolygonsDataFrame with the polygons.
My idea is to use something like:
for (i in 1:length(absUTMpolys at polygons)){
delme <- runifpoint(3, win=as.owin(absUTMpolys at polygons[i]))
...
but I'm not being successful at extracting each polygon and
as.owin refuses the conversion:
I've tried
> as(absUTMpolys at polygons[1], "owin")
Error in as(absUTMpolys at polygons[1], "owin") :
no method or default for coercing "list" to "owin"
and
> as(absUTMpolys at polygons[1][[1]], "owin")
Error in as(absUTMpolys at polygons[1][[1]], "owin") :
no method or default for coercing "Polygons" to "owin"
which is the proper way
of selecting each polygon from within the SpatialPolygonsDataFrame
object?
Thanks!
Agus
--
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: Agustin.Lobo at ija.csic.es
http://www.ija.csic.es/gt/obster
More information about the R-sig-Geo
mailing list