National Data Buoy Center#

To read NDBC data we suggest that you use the rnoaa package from rOpenSci.


You only need the rnoaa package to get data, but we include helper packages, dplyr and ggplot2, for the purpose of this tutorial.

  required <- c("dplyr", "ggplot2", "rnoaa")
  installed <- installed.packages() |>
  needed <- !(required %in% installed$Package)
  if (any(needed)){
  ok <- sapply(required, library, character.only = TRUE)

Generate a list of buoys, and, as an example, narrow the list to Gulf of Maine.#

bb <- c(xmin = -72, xmax = -63, ymin = 39, ymax = 46)
buoys <- buoy_stations() |>
  filter(between(lat, bb['ymin'], bb['ymax']),
         between(lon, bb['xmin'], bb['xmax']))


We select one buoy, Cutler Farris Wharf, in Maine and filter the listing down to just that one record (row).#

CFW_id <- buoys |>
filter(grepl("Cutler Farris Wharf", description, fixed = TRUE))


Now we can pull buoy data, but only one dataset, such as standard meteorology, for a single year at a time may be requested. The function yields a list of two elements…#

  • meta a list variable descriptions

  • data a data frame (tibble) with reported data

stdmet <- buoy("stdmet", CFW_id$station[1], year = 2021)

With just a little manipulation, we can start viewing the data graphically. First we must convert the timestamp data from character to numeric, specifically a POSIX timestamp (seconds of time since that start of an arbitrary origin, in this case 1970-01-01 00:00:00).

stdmet$data <- mutate(stdmet$data, time = as.POSIXct(time, format = "%Y-%m-%dT%H:%M:%SZ"))
sst_meta <- stdmet$meta$sea_surface_temperature

ggplot(data = stdmet$data, 
       aes(x = time, 
           y = sea_surface_temperature)) +
  geom_point(size = 0.2, alpha = 0.4) + 
  labs(title = sub("National Data Buoy Center - Recent observations from station ", 
       y = sprintf("%s\n(%s)", sst_meta$longname, sst_meta$units),
       x = "Date")