processNLCountry: Processes nightlights for an individual country in a...

Description Usage Arguments Details Value Examples

View source: R/nightlights.R

Description

Given a countryCode, yearMonth and preferred processing methods cropMaskMethod and extractMethod, this function will first check if the data already exists in the cache. First it will check if the data file exists and if it does not it will create a dataframe of the country data containing only the administrative properties and move to processing. If the data file exists it will check to see if the particular year month already exists. If it exists, it will exit with a message. If it does not exist, it will load the country data file and move on to processing.

Usage

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

Arguments

ctryCode

character The ctryCode of interest

admLevel

character The country admin level in the given ctryCode at which to calculate stats

nlType

character The nlType of interest

configName

character the config shortname 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

character The method to use to perform gas flare removal or NULL to disable

nlPeriod

character The nlPeriod of interest

nlStats

the statistics to calculate. If not provided will calculate the stats specified in pkgOptions("nlStats")

downloadMethod

The method used to download polygons and rasters

cropMaskMethod

character Whether to use rasterize or gdal-based functions to crop and mask the country rasters

extractMethod

("rast" or "gdal") Whether to use rasterize or gdal-based functions to crop and mask the country rasters

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

Details

Processing consists of:

NOTE: processNLCountry() assumes that all inputs are available and will not attempt to download them. It should ideally be called from the function processNlData() which does all the preparation for processing. processNlData() which can process multiple countries and time periods will download all the required tiles and polygons prior to calling processNlCountry. getCtryNlData can also be used with the option ignoreMissing=FALSE which will call processNlData in the background.

Value

None

Examples

1
2
3
4
5
6
#calculate only the sum of monthly VIIRS radiances for Dec 2014 using gdal
#for both cropMask and extraction for KEN
## Not run: 
Rnightlights:::processNLCountry("KEN", "KEN_adm2", "VIIRS.M", "201412", "gdal", "gdal", "sum")

## End(Not run)

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