Collect Ocean Data from NOAA

Provides a small set of tools for collecting data from National Oceanic and Atmospheric Administration (NOAA) data sources. The functions provided in the package are wrappers around NOAA's existing APIs which is found at < https://tidesandcurrents.noaa.gov/api/>.


CRAN status Build Status codecov

The noaaoceans package is designed to facilitate access to various National Oceanic and Atmospheric Administration (NOAA) data sources. The current version focuses on accessing data from the CO-OPS API. The package also facilitates the collection of basic metadata for each of the stations that collect the data available in the API.

Example

library(noaaoceans)
library(dplyr)
library(ggplot2)
library(maps)
library(mapdata)
 
# Get a list of all the stations.
station_df <- list_coops_stations()
 
# Filter to stations in Washington with Water Temp Sensor
wa_station <- station_df %>% 
    filter(station_state == 'WA' & water_temp == '1')
wa_station %>% dplyr::as_tibble(.) %>% head()
#> # A tibble: 6 x 15
#>   station_id station_names station_state station_lat station_long
#>   <chr>      <chr>         <chr>         <chr>       <chr>       
#> 1 9440422    Longview      WA            46.1061     -122.9542   
#> 2 9440910    Toke Point    WA            46.7075     -123.9669   
#> 3 9441102    Westport      WA            46.9043     -124.1051   
#> 4 9442396    La Push, Qui… WA            47.913      -124.6369   
#> 5 9443090    Neah Bay      WA            48.3703     -124.6019   
#> 6 9444090    Port Angeles  WA            48.1247     -123.4411   
#> # ... with 10 more variables: date_established <chr>, water_level <chr>,
#> #   winds <chr>, air_temp <chr>, water_temp <chr>, air_pressure <chr>,
#> #   conductivity <chr>, visibility <chr>, humidity <chr>, air_gap <chr>

Query API For Water Temperature Data

# Create an empty storage data frame. 
water_temp <- data.frame()
 
# Loop through the station and call the API for each station
for (i in wa_station$station_id) {
    query_df <- query_coops_data(station_id = i,
                                 start_date = '20181201',
                                 end_date = '20181231',
                                 data_product = 'water_temperature',
                                 interval = 'h') # hourly readings
    
    # Add current station results to the storage data frame 
    water_temp <- water_temp %>% bind_rows(., query_df)
}
 
water_temp %>% as_tibble(.) %>% head()
#> # A tibble: 6 x 4
#>   t                v     f     station
#>   <chr>            <chr> <chr> <chr>  
#> 1 2018-12-01 00:00 48.2  0,0,0 9440422
#> 2 2018-12-01 01:00 48.2  0,0,0 9440422
#> 3 2018-12-01 02:00 48.0  0,0,0 9440422
#> 4 2018-12-01 03:00 48.0  0,0,0 9440422
#> 5 2018-12-01 04:00 48.0  0,0,0 9440422
#> 6 2018-12-01 05:00 48.0  0,0,0 9440422

Plot the Average Water Temp

# Correct data types. 
water_temp <- water_temp %>% 
    mutate(v = as.numeric(v), t = as.POSIXct(t))
 
water_temp %>% 
    group_by(t) %>% 
    # Compute the hourly average. 
    summarise(avg_temp = mean(v, na.rm = TRUE)) %>% 
    # Plot the hourly average. 
    ggplot(aes(x = t, y = avg_temp)) +
    geom_path() +
    labs(x = "Date",
         y = 'Average Water Temperature',
         title = 'Average Hourly Water Temperature In Washington During December 2018')

News

noaaoceans 0.1.0 (2018-01-29)

  • First release of the package.
  • Functions to find NOAA's CO-OPS stations and query the CO-OPS API.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("noaaoceans")

0.1.0 by Sean Warlick, 8 months ago


Browse source code at https://github.com/cran/noaaoceans


Authors: Sean Warlick [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports httr, jsonlite, rvest, xml2

Suggests testthat, covr, knitr, rmarkdown, dplyr, httptest, ggplot2, maps, mapdata


See at CRAN