Skip to content

Commit

Permalink
token instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarty committed May 9, 2024
1 parent f7befe5 commit aa74b50
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions R/blackmarbler.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) %>%
Expand All @@ -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 ----------------------------------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ devtools::install_github("worldbank/blackmarbler")

## Bearer Token <a name="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

<p align="center">
<img src="man/figures/nasa_laads_login.png" alt="NASA LAADS Bearer Token" width="800"/>
Expand Down
Binary file added man/figures/_archive/nasa_laads_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/nasa_laads_login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit aa74b50

Please sign in to comment.