MyNixOS website logo
Description

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://api.tidesandcurrents.noaa.gov/api/prod/>.

CRANstatus Downloadcount Travis buildstatus AppVeyor buildstatus codecov

noaaoceans

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.

Installing

The current release of noaaoceans can be installed from CRAN.

install.packages('noaaoceans')

The development version can be installed via GitHub with remotes

remotes::install_github('warlicks/noaaoceans')

Examples

Find all the CO-OPS stations in Washington.

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.125      -123.44     
#> # … 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.4  0,0,0 9440422
#> 2 2018-12-01 01:00 48.4  0,0,0 9440422
#> 3 2018-12-01 02:00 48.4  0,0,0 9440422
#> 4 2018-12-01 03:00 48.4  0,0,0 9440422
#> 5 2018-12-01 04:00 48.4  0,0,0 9440422
#> 6 2018-12-01 05:00 48.4  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')
#> `summarise()` ungrouping output (override with `.groups` argument)

Metadata

Version

0.3.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows