Description Usage Arguments Details Value Author(s) Examples
'Zonal' operator of map algebra. Applied to raster images.
1 2 3 4  | 
x | 
 
  | 
by | 
 
  | 
FUN | 
 a function to compute the summary statistics which can be applied to all data subsets.  | 
table | 
 Logical. If   | 
... | 
 Other arguments which passed to function   | 
zonal_stat is a wrapper of aggregate(x,by,FUN,table=FALSE,na.rm=TRUE)
You can use multichannel image (argument x) for analysis.
You can use multichannel raster image for group elements (argument by)
If table=FALSE then ursaRaster object of summarized statistics.
If table=TRUE then data.frame.
Nikita Platonov platonov@sevin.ru
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  | session_grid(NULL)
session_grid(regrid(mul=1/2))
a <- pixelsize()
val <- c(normal=a,half=a/2)
gr <- c(group=colorize(a,nbreak=1))#+0
print(as.table(gr))
##~ display(gr)
ra <- round(aggregate(val,gr,mean),4)
print(ra)
print(as.table(ra[1]))
print(as.table(ra[2]))
da <- aggregate(val,gr,table=TRUE,mean)
n <- aggregate(a,gr,table=TRUE,length)[,2,drop=FALSE]
da <- cbind(da,n=unname(n))
gr2 <- c(group2=colorize(a,nbreak=6))#+0
mgr <- list(gr,gr2)
da2 <- aggregate(val[1],mgr,table=TRUE,mean)
print(da2)
da3 <- aggregate(val,mgr,table=TRUE,mean)
print(da3)
ra3 <- aggregate(val,mgr,table=FALSE,mean) ## not implemented for rasters
print(ra3)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.