bm_extract {blackmarbler} | R Documentation |
Extract and Aggregate Black Marble Data
Description
Extract and aggregate nighttime lights data from NASA Black Marble data
Usage
bm_extract(
roi_sf,
product_id,
date,
bearer,
aggregation_fun = c("mean"),
add_n_pixels = TRUE,
variable = NULL,
quality_flag_rm = NULL,
check_all_tiles_exist = TRUE,
interpol_na = FALSE,
output_location_type = "memory",
file_dir = NULL,
file_prefix = NULL,
file_skip_if_exists = TRUE,
file_return_null = FALSE,
h5_dir = NULL,
quiet = FALSE,
...
)
Arguments
roi_sf |
Region of interest; sf polygon. Must be in the WGS 84 (epsg:4326) coordinate reference system. |
product_id |
One of the following:
|
date |
Date of raster data. Entering one date will produce a
|
bearer |
NASA bearer token. For instructions on how to create a token, see here. |
aggregation_fun |
Function used to aggregate nighttime lights data to polygons; this values is passed to the |
add_n_pixels |
Whether to add a variable indicating the number of nighttime light pixels used to compute nighttime lights statistics (eg, number of pixels used to compute average of nighttime lights). When |
variable |
Variable to used to create raster (default:
|
quality_flag_rm |
Quality flag values to use to set values to For
For
|
check_all_tiles_exist |
Check whether all Black Marble nighttime light tiles exist for the region of interest. Sometimes not all tiles are available, so the full region of interest may not be covered. If |
interpol_na |
When data for more than one date is downloaded, whether to interpolate |
output_location_type |
Where to produce output; either |
file_dir |
(If |
file_prefix |
(If |
file_skip_if_exists |
(If |
file_return_null |
Whether to return |
h5_dir |
Black Marble data are originally downloaded as |
quiet |
Suppress output that show downloading progress and other messages. (Default: |
... |
Additional arguments for |
Value
Raster
Examples
## Not run:
# Define bearer token
bearer <- "BEARER-TOKEN-HERE"
# sf polygon of Ghana
library(geodata)
roi_sf <- gadm(country = "GHA", level=1, path = tempdir()) %>% st_as_sf()
# Daily data: raster for October 3, 2021
ken_20210205_r <- bm_extract(roi_sf = roi_sf,
product_id = "VNP46A2",
date = "2021-10-03",
bearer = bearer)
# Monthly data: raster for March 2021
ken_202103_r <- bm_extract(roi_sf = roi_sf,
product_id = "VNP46A3",
date = "2021-03-01",
bearer = bearer)
# Annual data: raster for 2021
ken_2021_r <- bm_extract(roi_sf = roi_sf,
product_id = "VNP46A4",
date = 2021,
bearer = bearer)
## End(Not run)