masqVIIRS: extract data from a raster using one polygon in a...

Description Usage Arguments Value Examples

View source: R/masq.R

Description

extract data from a raster using one polygon in a multipolygon.

Usage

1
masqVIIRS(ctryPoly, ctryRast, idx, retVal = NULL, configName, extension)

Arguments

ctryPoly

the country Polygon layer as SpatialPolygon

ctryRast

the clipped country raster

idx

the index of the polygon in the country polygon layer (shp)

retVal

Whether to return the raster data as a vector, or data.frame with spatial context NULL returns a vector of all values, colrowval returns a data.frame with row, col and raster value while lonlatval returns a data.frame with lon,lat and val.

configName

character the config shortname of raster being processed

extension

character the extension of raster being processed

Value

numeric vector of radiances

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
ctryPoly <- rgdal::readOGR('path/to/polygon.shp')

ctryRaster <- raster::raster('path/to/raster.tif')

#get the sum of nightlight pixels in the first polygon in a multipolygon
sumPolygon1 <- sum(masqVIIRS(ctryPoly, ctryRaster, 1), na.rm=T)

## End(Not run)

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