This function downloads buoy data from various programs including, as listed in ‘Details’.
Arguments
- program
argument specifying the desired oceanographic program to download buoy data from. This must be either
"MEDS"
or"smartatlantic"
.- ID
a character value indicating the ID of the instrument (see ‘Details’)
- destdir
a character value indicating the directory in which to store downloaded files.
- age
a numerical value indicating a time interval, in days. If the file to be downloaded from the server already exists locally, and was created less than
age
days in the past, it will not be downloaded again. Settingage=0
forces a download, so that existing files will always be updated. By contrast, settingage
to a negative number prevents the updating of files that already exist locally, regardless of their age.- debug
an integer value indicating the level of debugging. If this exceeds 0, then some debugging messages will be printed. This value is passed down to related functions, but with 1 subtracted for each pass.
Value
If index
is TRUE, and program
is "BBMP"
or "BATS"
,
return a data frame. Otherwise, return the name of the
downloaded file.
Details
If program
is `"MEDS"', then the choices for ID are as follows.
"Banquereau Bank"
"East Scotian Slope"
"Halifax"
"Halifax DISCUS TriAx"
"Halifax Harbour"
"Laurentian Fan"
"Minas Basin"
"Port Hope"
"Prince Edward Point"
"Tail of the Bank"
If program
is `"smartatlantic"', then the choices, all for
buoys in the Atlantic Provinces, are as follows.
"h1"
for a buoy near Duncan Reef, Nova Scotia (see https://www.smartatlantic.ca/station_alt.html?id=halifax_h1)"halifax"
for a buoy in Herring Cove, Nova Scotia (see https://www.smartatlantic.ca/station_alt.html?id=halifax)"hkb"
for a buoy near Meagher's Beach, Nova Scotia (see https://www.smartatlantic.ca/station_alt.html?id=halifax_hk4)"saint_john"
for a buoy in the Bay of Fundy, near St John, New Brunswick (see https://www.smartatlantic.ca/station_alt.html?id=saintjohn)"saint_johns"
for a buoy near St John's Harbour, Newfoundland (see https://www.smartatlantic.ca/station_alt.html?id=stjohns)
See also
Other functions that download files:
dod.amsr()
,
dod.coastline()
,
dod.ctd()
,
dod.ctd.bats()
,
dod.ctd.bbmp()
,
dod.ctd.gtspp()
,
dod.ctd.itp()
,
dod.met()
,
dod.tideGauge()
,
dod.topo()
Examples
# Show significant wave height in Halifax Harbour over past 28 days.
if (interactive()) { # sidestep a pkgdown::build_site() error
# NOTE: data file is removed at end, to pass CRAN checks
library(dod)
destdir <- tempdir()
file <- dod.buoy("smartatlantic", "h1", destdir = destdir)
col.names <- strsplit(readLines(file, 1), ",")[[1]]
d <- read.csv(file, skip = 2, col.names = col.names)
d$t <- as.POSIXct(d$time, tz = "UTC", format = "%Y-%m-%dT%H:%M:%SZ")
look <- d$t > (max(d$t, na.rm = TRUE) - 28 * 86400)
plot(d$t[look], d$wave_ht_sig[look],
type = "l", xaxs = "i",
xlab = "", ylab = "Sig. Wave Ht. [m]"
)
unlink(destdir, recursive = TRUE)
}