Learn R Programming

PAMmisc (version 1.12.4)

formatURL: Format URL for Environmental Data Download

Description

This creates a properly formatted URL for downloading environmental data either from an ERDDAP or HYCOM server. This URL can be pasted into a browser or submitted to something like httr::GET to actually download the data. Also see edinfoToURL

Usage

formatURL(
  base,
  dataset,
  fileType,
  vars,
  ranges,
  stride = 1,
  style = c("erddap", "hycom")
)

Value

a properly formatted URL that can be used to download environmental data

Arguments

base

the base URL to download from

dataset

the specific datased ID to download

fileType

the type of file to download, usually a netcdf

vars

a vector of variables to download

ranges

a list of three vectors specifying the range of data to download, must a list with named vectors Longitude, Latitude, and UTC where each vector is c(min, max) (Note: even if the time is something like "dayOfYear" this should still be called 'UTC' for the purpose of this list). (see dataToRanges).

stride

the stride for all dimensions, a value of 1 gets every data point, 2 gets every other, etc.

style

either 'erddap' or 'hycom'

Author

Taiki Sakai taiki.sakai@noaa.gov

Examples

Run this code

formatURL(
    base = "https://upwell.pfeg.noaa.gov/erddap/griddap/",
    dataset = "jplMURSST41",
    fileType = "nc",
    vars = "analysed_sst",
    ranges = list(
               Latitude = c(30, 31),
               Longitude = c(-118, -117),
               UTC = as.POSIXct(c('2005-01-01 00:00:00', '2005-01-02 00:00:00'), tz='UTC')
             ),
    stride=1,
    style = 'erddap'
)

Run the code above in your browser using DataLab