Learn R Programming

blackmarbler (version 0.2.5)

wget_h5_files: Download h5 files using wget

Description

Download h5 files from from NASA Black Marble data using wget. The wget_h5_files() function requires the wget command line tool to be installed on your system. If you do not have wget installed, please install it from https://www.gnu.org/software/wget/.

Usage

wget_h5_files(roi_sf = NULL, product_id, date, h5_dir, bearer)

Value

NULL

Arguments

roi_sf

Region of interest; sf polygon. Must be in the WGS 84 (epsg:4326) coordinate reference system. If NULL, all h5 files for the inputted date(s) are downloaded.

product_id

One of the following:

  • "VNP46A1": Daily (raw)

  • "VNP46A2": Daily (corrected)

  • "VNP46A3": Monthly

  • "VNP46A4": Annual

date

Date(s) to download h5 files.

  • For product_ids "VNP46A1" and "VNP46A2", a date (eg, "2021-10-03").

  • For product_id "VNP46A3", a date or year-month (e.g., "2021-10-01", where the day will be ignored, or "2021-10").

  • For product_id "VNP46A4", year or date (e.g., "2021-10-01", where the month and day will be ignored, or 2021).

h5_dir

Path to download h5 files to.

bearer

NASA bearer token. For instructions on how to create a token, see here.

Author

Robert Marty rmarty@worldbank.org

Examples

Run this code
if (FALSE) {
# 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()

# h5 files for Ghana for October 3, 2021
download_h5_files(roi_sf = roi_sf,
                  product_id = "VNP46A2",
                  date = "2021-10-03",
                  h5_dir = getwd(),        
                  bearer = bearer)

# Make raster using h5_files
ken_202103_r <- bm_raster(roi_sf = roi_sf,
                          product_id = "VNP46A3",
                          date = "2021-03-01",
                          bearer = bearer,
                          h5_dir = getwd())

}

Run the code above in your browser using DataLab