G'day All,

I have a tree cover layer that I clumped() to produce patches of contiguous forest. I want to use PatchStat() to get the perim.area.ratio for each patch and then create a new raster where every cell has a value corresponding to the perim.area.ration of the patch it is in. When I try to get the PatchStat() from my clump raster I get this error:

library(raster)
library(SDMTools)
clump<-raster(file.choose())
psclump<-PatchStat(clump)

Error in if (m[ii] == 0) minp[ii] = 4 * n[ii] :
  missing value where TRUE/FALSE needed

I can get the PatchStat stuff if I make clump a matrix:

ps.data<-PatchStat(as.matrix(clump))

Which I tried to merge with a data.frame I made from the clump raster using layer and patchID.


clumpval<-rasterToPoints(clump)
clumpcell<- cellFromXY(clump, clumpval[, c('x', 'y')] )
clumpdf<-data.frame(clumpval, clumpcell)

merged.data.all <- merge(clumpdf, ps.data1, by=c("layer", "patchID"))



However, I get this error:



Errors in fix.by(by.x, x) : 'by' must specify valid column(s).



Any ideas how I can do this? My raster is quite large with lots of cells, could this be why SDMTools PatchStat won't work with my RasterLayer? Any help or suggestions would be greatly appreciated.



Regards,

Adam

	[[alternative HTML version deleted]]

