fnAggRadRast: Calculate statistics on a nightlight raster that fall within...

Description Usage Arguments Value Examples

View source: R/stats.R

Description

Calculate stats on the radiance of the pixels in a nightlight raster that fall within a polygon and its subpolygons using the raster package. Given a country polygon with subpolygons representing lower admin levels, it will crop and mask the raster to each subpolygon and calculate the total radiance for the polygon and return a vector of total radiances that matches the subpolygons

Usage

1
2
3
4
5
6
7
8
9
fnAggRadRast(
  ctryPoly,
  ctryRastCropped,
  nlType,
  configName,
  extension,
  nlStats,
  custPolyPath = NULL
)

Arguments

ctryPoly

The polygon of the admin level/region of interest. In general is a country polygon with sub-regions usually the lowest known admin level as given by the GADM polygons.

ctryRastCropped

The raster containing nightlight radiances to sum. Usually will have already be cropped to the country outline

nlType

Character vector The nlType to process

configName

character the config short name of raster being processed

extension

character the extension of raster being processed

nlStats

The statistics to calculate

custPolyPath

Alternative to GADM. A path to a custom shapefile zip

Value

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

Examples

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

# the VIIRS nightlight raster cropped earlier to the country outline
ctryRastCropped <- raster::raster(Rnightlights:::getCtryRasterOutputFnamePath(ctryCode="KEN",
    nlType="VIIRS.M", nlPeriod="201401"))

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

## End(Not run)

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