Dear list,

Im trying to calculate the centroid of each clump existent within a raster
layer.

So far I reached to:
require(raster)
r <- raster(ncols=12, nrows=12)
set.seed(0)
r[] <- round(runif(ncell(r))*0.7 )
r=r>0.3
rc <- clump(r)

# the function should be something like this, but im still sorting it out

centerer=function(x,na.rm){
  require(rgeos)
  coor =rasterToPoints(x,spatial=T)
  cent=gcentroid(coord)
  return(cent)                  }

#then, I want to apply the function to each clump
# i tried this:

coor <- zonal(r, rc,'centerer', na.rm=TRUE)# summing the cells of each group

Error in (function (classes, fdef, mtable)  :
  unable to find an inherited method for function ‘nlayers’ for
signature ‘"logical"’


Anybody could give me any hint to obtain coordinates per clump?

Thanks in advance
Agus
-- 
Agustín Camacho Guerrero.
Doutor em Zoologia.
Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
Biociências, USP.
Rua do Matão, trav. 14, nº 321, Cidade Universitária,
São Paulo - SP, CEP: 05508-090, Brasil.

	[[alternative HTML version deleted]]

