Skip to content

Instantly share code, notes, and snippets.

@g4brielvs
Last active July 18, 2024 22:52
Show Gist options
  • Save g4brielvs/d7f1a7dfcd4dadaf9fe806df78331fe2 to your computer and use it in GitHub Desktop.
Save g4brielvs/d7f1a7dfcd4dadaf9fe806df78331fe2 to your computer and use it in GitHub Desktop.
BlackMarbleR Example
library(blackmarbler)
library(geodata)
library(sf)
# Set NASA EarthData Token
bearer <- "NASA-EARTHDATA-TOKEN"
# Retrieve GADM polygon of Lebanon
roi <- gadm(country = "LBN",
level=1,
path = tempdir()) |>
st_as_sf()
# Create NTL raster
ntl_r <- bm_raster(roi_sf = roi,
product_id = "VNP46A4",
date = 2019:2022,
bearer = bearer)
# Create NTL dataset from 2012 to 2022
ntl_df <- bm_extract(roi_sf = roi,
product_id = "VNP46A4",
date = 2012:2022,
bearer = bearer,
aggregation_fun = "sum")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment