fnAggRadGdal: Calculate zonal statistics using GDAL

Description Usage Arguments Value Examples

View source: R/stats.R

Description

Calculate zonal statistics using GDAL. Alternative to fnAggRadRast and faster. Modified from http://www.guru-gis.net/efficient-zonal-statistics-using-r-and-gdal/

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
fnAggRadGdal(
  ctryCode,
  admLevel,
  ctryPoly,
  nlType,
  configName = pkgOptions(paste0("configName_", nlType)),
  extension,
  multiTileStrategy = pkgOptions("multiTileStrategy"),
  multiTileMergeFun = pkgOptions("multiTileMergeFun"),
  removeGasFlaresMethod = pkgOptions(paste0("removeGasFlaresMethod_", nlType)),
  nlPeriod,
  nlStats = pkgOptions("nlStats"),
  gadmVersion = pkgOptions("gadmVersion"),
  gadmPolyType = pkgOptions("gadmPolyType"),
  custPolyPath = NULL
)

Arguments

ctryCode

character string the ISO3 country code to be processed

admLevel

character string The admin level to process. Should match the ctryPoly given but no checks are made currently.

ctryPoly

Polygon the loaded country polygon layer

nlType

the nlType of interest

configName

character the config short name of raster being processed

extension

character the extension of raster being processed

multiTileStrategy

character How to handle multiple tiles per nlPeriod

multiTileMergeFun

character The function to use to merge tiles

removeGasFlaresMethod

logical Whether to perform gas flare removal pre-processing

nlPeriod

character string the nlPeriod to be processed

nlStats

character vector The stats to calculate

gadmVersion

The GADM version to use

gadmPolyType

The format of polygons to download from GADM

custPolyPath

Alternative to GADM. A path to a custom shapefile zip

Value

data.frame of polygon attributes and the calculated stats, one column per stat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
#read the Kenya polygon downloaded from GADM and load the lowest admin level (ward)
## Not run: 
ctryPoly <- readCtryPolyAdmLayer(ctryCode="KEN",
    Rnightlights:::getCtryShpLowestLyrNames(ctryCodes="KEN"))

#calculate the sum of radiances for the wards in Kenya
sumAvgRadRast <- Rnightlights:::fnAggRadGdal(ctryCode="KEN", ctryPoly=ctryPoly,
    nlType="VIIRS.M", nlPeriod="201401", nlStats=c("sum","mean"))

## End(Not run)

chrisvwn/Rnightlights documentation built on Sept. 7, 2021, 1:44 a.m.