Skip to content

get coordinates of centroids in a SpatialGridDataFrame object.

2 messages · Paulo Cardoso, Roger Bivand

#
On Tue, 14 Jul 2009, Paulo E. Cardoso wrote:

            
If you are thinking of "connected components", try labcon() in adehabitat:

library(adehabitat)
data(puechabon)
hr <- getsahrlocs(puechabon$sahr, "hr")
u <- getkasc(hr, "Jean")
p <- labcon(u)
c2a <- kasc2spixdf(as.kasc(list(p)))
names(c2a) <- "patches"
image(c2a)
c2b <- as.SpatialPolygons.SpatialPixels(c2a)
library(maptools)
c2c <- unionSpatialPolygons(c2b, c2a$patches)
plot(c2c, axes=TRUE)
points(coordinates(c2c), pch=3)

How this scales for your data is another matter.

Roger