zonalStat: High performance zonal statistics function.

Description Usage Arguments Value Examples

Description

This function calculate statistics for each zone defined by a zone dataset.

Usage

1
2
zonalStat(x, zonal.ras, stat = "mean", digits = 0, na.rm = T,
  prefix = "zonal", ...)

Arguments

x

the raster dataset to be calculated

zonal.ras

a raster objects indicating each zone

stat

character.statistics method to be performed.The defautl value is 'mean'.

na.rm

logic indicating whether to remove NA value during the zonal statistic.The default value is true

prefix

character indicating column name prefix of zonal statistical value.

digit

integer indicating the number of decimal places (round) for zone id.The default value is 0.

Value

RasterLayer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
gg<-loadGRID()
res.test<-1e4
zonal.ras<-rasterize.gdal(china.pop[,'county_ID'],'county_ID',res=res.test)
grid.poly.proj<-gg%>%spTransform(proj4string(china.pop))
o3.test1<-rasterize.gdal(grid.poly.proj,names(grid.poly.proj)[2],res=res.test,
                         extent=extent(china.pop))
zonal.test<-zonalStat(zonal.ras,val.ras =o3.test1)
##############  batch processing ######
o3.stack.3<-lapply(names(grid.poly.proj)[-1],rasterize.gdal,
x=grid.poly.proj,res=res.test,extent=extent(china.pop))
zonal.res.all<-lapply(X=o3.stack.3,FUN = zonalStat,zonal.ras=zonal.ras)

seifer08ms/ROzone2 documentation built on May 29, 2019, 5:53 p.m.