Title: | Black Marble Data and Statistics |
---|---|
Description: | Geographically referenced data and statistics of nighttime lights from NASA Black Marble <https://blackmarble.gsfc.nasa.gov/>. |
Authors: | Robert Marty [aut, cre] , Gabriel Stefanini Vicente [aut] |
Maintainer: | Robert Marty <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2024-11-05 23:19:04 UTC |
Source: | https://github.com/worldbank/blackmarbler |
Extract and aggregate nighttime lights data from NASA Black Marble data
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, ... )
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, ... )
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 |
Raster
## 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)
## 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)
Make a raster of nighttime lights from NASA Black Marble data
bm_raster( roi_sf, product_id, date, bearer, 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, ... )
bm_raster( roi_sf, product_id, date, bearer, 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, ... )
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. |
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 |
The directory where data should be exported (default: |
file_prefix |
Prefix to add to the file to be saved. The file will be saved as the following: |
file_skip_if_exists |
Whether the function should first check wither the file already exists, and to skip downloading or extracting data if the data for that date if the file already exists (default: |
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 |
Raster
## Not run: # Define bearer token bearer <- "BEARER-TOKEN-HERE" # sf polygon of Ghana library(geodata) roi_sf <- gadm(country = "GHA", level=0, path = tempdir()) %>% st_as_sf() # Daily data: raster for October 3, 2021 ken_20210205_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A2", date = "2021-10-03", bearer = bearer) # Monthly data: raster for March 2021 ken_202103_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A3", date = "2021-03-01", bearer = bearer) # Annual data: raster for 2021 ken_2021_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A4", date = 2021, bearer = bearer) ## End(Not run)
## Not run: # Define bearer token bearer <- "BEARER-TOKEN-HERE" # sf polygon of Ghana library(geodata) roi_sf <- gadm(country = "GHA", level=0, path = tempdir()) %>% st_as_sf() # Daily data: raster for October 3, 2021 ken_20210205_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A2", date = "2021-10-03", bearer = bearer) # Monthly data: raster for March 2021 ken_202103_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A3", date = "2021-03-01", bearer = bearer) # Annual data: raster for 2021 ken_2021_r <- bm_raster(roi_sf = roi_sf, product_id = "VNP46A4", date = 2021, bearer = bearer) ## End(Not run)