blackmaRble: retrieve, wrangle and plot VIIRS Black Marble nighttimelight data in R
Install with:
library(devtools)
install_github("https://github.com/giacfalk/blackmaRble")
Operate the package as follows, replacing username and password with your EarthData (https://urs.earthdata.nasa.gov/users/new) login data.
library(blackmaRble)
bm_initialize("username", "password")
output <- bm_get_data( date_start="2019-09-15", date_end='2019-09-16', delta='days', data_product='VNP46A2', variable_name="Gap_Filled_DNB_BRDF_Corrected_NTL", custom_shape=NULL)
where:
as.Date
https://ladsweb.modaps.eosdis.nasa.gov/missions-and-measurements/products/VNP46A1/ https://ladsweb.modaps.eosdis.nasa.gov/missions-and-measurements/products/VNP46A2/ https://ladsweb.modaps.eosdis.nasa.gov/missions-and-measurements/products/VNP46A3/
sf
simple feature polygon defining an area where to download and crop the dataThe resulting data is a regular RasterStack object, as seen by running output
:
> output
class : RasterStack
dimensions : 73, 108, 7884, 2 (nrow, ncol, ncell, nlayers)
resolution : 0.004166666, 0.004166667 (x, y)
extent : 32.37917, 32.82917, 0.1500007, 0.4541673 (xmin, xmax, ymin, ymax)
crs : +proj=longlat +datum=WGS84 +no_defs
names : X2019.09.15, X2019.09.16
min values : 0, 0
max values : 75.8, 75.8
and plotting the object with bm_plot(output)
:
This package is developed by a data user, and is thus not linked or endorsed in any way by NASA or the Black Marble data proudct development team. Whilst the primary data quality does not depend on the blackmaRble package, any residual coding error affecting the data output remains the sole responsibility of the package maintainer.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.