R/getRaster.R

Defines functions getRaster

Documented in getRaster

getRaster <- function(var = 'swflx',
                      day = Sys.Date(), run = '00',
                      frames = 'complete', box,
                      resolution = NULL,
                      names,
                      remote = TRUE, 
                      service = mfService(),
                      dataDir = '.',
                      use00H = FALSE,
                      ...){

    service <- matchService(service)
    stopifnot(frames == 'complete' | is.numeric(frames))
    ## Set working directory depending on 'remote'
    if (remote) {
        old <- setwd(tempdir())
        on.exit(setwd(old))
    } else {
        old <- setwd(dataDir)
        on.exit(setwd(old))
    }
    ## Which function to use
    fun <- switch(service,
                  meteogalicia = 'rasterMG',
                  gfs = 'rasterGFS',
                  nam = 'rasterNAM',
                  rap = 'rasterRAP')

    b <- do.call(fun, list(var = var, day = as.Date(day),
                           run = run, frames = frames[1],
                           box = if (missing(box)) NULL else box,
                           resolution = resolution,
                           names = if (missing(names))  NULL else names,
                           remote = remote, use00H = use00H))

}

Try the meteoForecast package in your browser

Any scripts or data that you put into this service are public.

meteoForecast documentation built on March 31, 2023, 9:51 p.m.