This document will be used within a cron job to update National Water Model forecasts for the FlowFinder application:
library(ncdf4) library(leaflet) source("./R/get_nomads_filelist.R") source("./R/download_nomads_rda.R") source("./R/flood_risk_map.R")
First, get a list of most current files on the NOMADs server:
fileList = get_nomads_filelist(num = 4) message("Date:\n", fileList$date, "\n\nTime:\n",fileList$startTime, "\n\nFiles:\n", paste(basename(fileList$urls), collapse ="\n"), "\n\n")
Check if files need to be updated, and, if so, download them:
file = list.files("./data/current_nc", full.names = F) if(length(file) > 0){ ttt = strsplit(list.files("./data/current_nc", full.names = F), "_")[[1]] date = ttt[1] time = ttt[2] forecast = ttt[3] } else { date = as.Date("1900-01-01") time = "50" forecast = "XXX" } if(all( fileList$date == date, fileList$startTime == time )){ message("No Download needed...") } else { file.remove(list.files("./inst/flowlinefinder/data/current_nc", full.names = T)) download_nomads_rda(fileList, number = 4, dir = here::here("inst/flowfinder")) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.