[R-sig-Geo] extracting polygons
Andrew Niccolai
andrew.niccolai at yale.edu
Tue Apr 8 15:09:07 CEST 2008
Try this code from my dataset:
## Read in var crown circular model
crown.shp <-
"C:/Niccolai/01_PhD/Papers/Paper003/GIS_LAYERS/CB_CRLOCS_ADJ_ALL_PREDINT99_B
uffer.shp"
crown.poly <- readShapePoly(crown.shp)
crown.data <-
read.dbf("C:/Niccolai/01_PhD/Papers/Paper003/GIS_LAYERS/CB_CRLOCS_ADJ_ALL_PR
EDINT99_Buffer.dbf")
head(crown.data)
## Visualize the newly created poly object.
plot(crown.poly, col="orange", main="")
crown.super.io <- list(crown.poly[1,])
looplen <- nrow(crown.data)
for ( i in 2:looplen){
i <- list(crown.poly[i,])
crown.super.io <- c(crown.super.io, i)
}
plot(crown.super.io[[1]], col="blue", add=TRUE)
Hope that helps!
Andrew Niccolai
Doctoral Candidate
Yale School of Forestry
-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Agustin Lobo
Sent: Tuesday, April 08, 2008 9:02 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: [R-sig-Geo] extracting polygons
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
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list