diff --git a/R/blackmarbler.R b/R/blackmarbler.R index 9f65c41..7f1d446 100644 --- a/R/blackmarbler.R +++ b/R/blackmarbler.R @@ -195,7 +195,7 @@ file_to_raster <- function(f, #### Daily if(f %>% str_detect("VNP46A1|VNP46A2")){ - tile_i <- f %>% str_extract("h\\d{2}v\\d{2}") + tile_i <- f %>% stringr::str_extract("h\\d{2}v\\d{2}") bm_tiles_sf <- read_sf("https://raw.githubusercontent.com/worldbank/blackmarbler/main/data/blackmarbletiles.geojson") grid_i_sf <- bm_tiles_sf[bm_tiles_sf$TileID %in% tile_i,] @@ -461,6 +461,10 @@ download_raster <- function(file_name, progress()) } + url1 <<- url + headers1 <<- headers + download_path1 <<- download_path + if(response$status_code != 200){ message("Error in downloading data") message(response) @@ -1178,7 +1182,7 @@ bm_raster_i <- function(roi_sf, # Remove grid along edges, which causes st_intersects to fail bm_tiles_sf <- bm_tiles_sf[!(bm_tiles_sf$TileID %>% str_detect("h00")),] bm_tiles_sf <- bm_tiles_sf[!(bm_tiles_sf$TileID %>% str_detect("v00")),] - + inter <- tryCatch( { inter <- st_intersects(bm_tiles_sf, roi_sf, sparse = F) %>% @@ -1191,7 +1195,7 @@ bm_raster_i <- function(roi_sf, stop("Issue with `roi_sf` intersecting with blackmarble tiles; try buffering by a width of 0: eg, st_buffer(roi_sf, 0)") } ) - + grid_use_sf <- bm_tiles_sf[inter > 0,] # Make Raster ---------------------------------------------------------------- diff --git a/README.md b/README.md index de00485..f3e69db 100644 --- a/README.md +++ b/README.md @@ -45,14 +45,15 @@ devtools::install_github("worldbank/blackmarbler") ## Bearer Token -The function requires using a **Bearer Token**; to obtain a token, follow the below steps: +The function requires using a **Earthdata Download Bearer Token**; to obtain a token, follow the below steps: 1. Go to the [NASA LAADS Archive](https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/5000/VNP46A3/) -2. Click "Login" (bottom on top right); create an account if needed. -3. Click "See wget Download Command" (bottom near top, in the middle) -4. After clicking, you will see text that can be used to download data. The "Bearer" token will be a long string in red. - -**After logging in, the below will show the bearer token in red instead of `INSERT_DOWNLOAD_TOKEN_HERE`.** Sometimes, after logging in, the NASA website will redirect to another part of the website. To obtain the bearer token, just navigate to the [NASA LAADS Archive](https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/5000/VNP46A3/) after logging in. +2. Click "Login" (button on top right), and click "Earthdata Login"; create an account if needed. +3. Once logged on, from the [NASA LAADS Archive](https://ladsweb.modaps.eosdis.nasa.gov/archive/allData/5000/VNP46A3/) page, click "Login" again +4. Click "Generate Token" from the dropdown menu +5. Click the "Generate Token" link that appears in a row of links +6. Click the green "Generate token" button +7. Click the blue "Show token" button; this is your bearer token

NASA LAADS Bearer Token diff --git a/man/figures/_archive/nasa_laads_login.png b/man/figures/_archive/nasa_laads_login.png new file mode 100644 index 0000000..748de54 Binary files /dev/null and b/man/figures/_archive/nasa_laads_login.png differ diff --git a/man/figures/nasa_laads_login.png b/man/figures/nasa_laads_login.png index 748de54..9541432 100644 Binary files a/man/figures/nasa_laads_login.png and b/man/figures/nasa_laads_login.png differ