[R] how to get points from SpatialPolygonsDataFrame

Takatsugu Kobayashi tkobayas at indiana.edu
Mon Feb 4 08:12:21 CET 2008


try

tmp<- slot(ex_1.7.selected, 'polygons')
sub.tmp <- slot(tmp[[1]],'Polygons')
sub.tmp[[1]]@coords

will get you there.

taka

Jarek Jasiewicz wrote:
> Milton Cezar Ribeiro wrote:
>   
>> Dear all,
>>
>> I need to get all points for each polygons and save these points in a data.frame. I tryed to use the slot() function, but I can´t access the "coords". 
>>
>> grd <- GridTopology(c(1,1), c(1,1), c(10,10))
>> polys <- as.SpatialPolygons.GridTopology(grd)
>> centroids <- coordinates(polys)
>> x <- centroids[,1]
>> y <- centroids[,2]
>> z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x
>> ex_1.7 <- SpatialPolygonsDataFrame(polys, data=data.frame(x=x, y=y, z=z, row.names=sapply(slot(polys, "polygons"), function(i) slot(i, "ID"))))
>> ex_1.7.selected<-ex_1.7[1,]
>> slot(ex_1.7.selected,"coords")
>>
>> Any idea?
>>
>> Kind regards,
>>
>> Miltinho
>>
>>
>>
>>  para armazenamento!
>>
>> 	[[alternative HTML version deleted]]
>>
>>   
>> ------------------------------------------------------------------------
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>   
>>     
> probably as.data.frame(spPointsDataFrame) will help
> look maptools package
> Jarek
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list