-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Additional Analysis for Readme | ||
|
||
#### Setup | ||
# Load packages | ||
library(blackmarbler) | ||
library(geodata) | ||
library(sf) | ||
library(raster) | ||
library(ggplot2) | ||
|
||
#### Define NASA bearer token | ||
bearer <- "BEARER-TOKEN-HERE" | ||
bearer <- read.csv("~/Desktop/bearer_bm.csv")$token | ||
|
||
### ROI | ||
# Define region of interest (roi). The roi must be (1) an sf polygon and (2) | ||
# in the WGS84 (epsg:4326) coordinate reference system. Here, we use the | ||
# getData function to load a polygon of Ghana | ||
roi_sf <- gadm(country = "NER", level=0, path = tempdir()) |> st_as_sf() | ||
|
||
### Daily data: raster for February 5, 2021 | ||
r <- bm_raster(roi_sf = roi_sf, | ||
product_id = "VNP46A4", | ||
date = "2021", | ||
bearer = bearer, | ||
variable = "NearNadir_Composite_Snow_Free") | ||
|
||
r_cf <- bm_raster(roi_sf = roi_sf, | ||
product_id = "VNP46A2", | ||
date = "2023-07-23", | ||
bearer = bearer, | ||
variable = "Gap_Filled_DNB_BRDF-Corrected_NTL") | ||
r_cf[] <- as.numeric(r_cf[] == 0) | ||
plot(r_cf) | ||
|
||
|
||
r <- bm_raster(roi_sf = roi_sf, | ||
product_id = "VNP46A2", | ||
date = "2023-07-23", | ||
bearer = bearer, | ||
variable = "Gap_Filled_DNB_BRDF-Corrected_NTL", | ||
quality_flag_rm = c(255)) | ||
|
||
r[] <- log(r[] + 1) | ||
plot(r) |