Skip to content

Instantly share code, notes, and snippets.

@khufkens
Created November 4, 2021 15:22
Show Gist options
  • Save khufkens/e296102d224fa7393e306e5a7cfff660 to your computer and use it in GitHub Desktop.
Save khufkens/e296102d224fa7393e306e5a7cfff660 to your computer and use it in GitHub Desktop.
Download Plumber 2 data
library(rvest)
# base html url
url <- "http://dapds00.nci.org.au/thredds/fileServer/ks32/CLEX_Data/PLUMBER2/v1-0/Flux/"
# catalogue
html_page = read_html("https://dap.nci.org.au/thredds/remoteCatalogService?catalog=http://dapds00.nci.org.au/thredds/catalog/ks32/CLEX_Data/PLUMBER2/v1-0/Flux/catalog.xml")
# grab files from the catalogue
files = html_page %>%
html_nodes("a") %>%
html_text()
# remove readme and stuff (only retain nc)
files <- files[grepl("*.nc",files)]
# set destination path
dest_path <- "~/data/plumber2"
# loop over all files
lapply(files, function(file){
download.file(file.path(url, file), file.path(dest_path,file))
})
@khufkens
Copy link
Author

khufkens commented Nov 4, 2021

update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment