working with buoy data
Scott Chamberlain
2020-07-27
Source:vignettes/buoy_vignette.Rmd
buoy_vignette.Rmd
This vignette covers NOAA buoy data from the National Buoy Data
Center. The main function to get data is buoy
, while
buoys
can be used to get the buoy IDs and web pages for
each buoy.
Find out what buoys are available in a dataset
res <- buoys(dataset = "cwind")
Inspect the buoy ids, and the urls for them
head(res)
#> id
#> 1 41001
#> 2 41002
#> 3 41004
#> 4 41006
#> 5 41008
#> 6 41009
#> url
#> 1 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41001/catalog.html
#> 2 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41002/catalog.html
#> 3 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41004/catalog.html
#> 4 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41006/catalog.html
#> 5 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41008/catalog.html
#> 6 https://dods.ndbc.noaa.gov/thredds/catalog/data/cwind/41009/catalog.html
Or browse them on the web
browseURL(res[1, 2])
Get buoy data
With buoy
you can get data for a particular dataset,
buoy id, year, and datatype.
Get data for a buoy
if no year or datatype specified, we get the first file
buoy(dataset = 'cwind', buoyid = 46085)
#> Using c2007.nc
#> Dimensions (rows/cols): [33486 X 5]
#> 2 variables: [wind_dir, wind_spd]
#>
#> # A tibble: 33,486 x 5
#> time lat lon wind_dir wind_spd
#> <chr> <dbl> <dbl> <int> <dbl>
#> 1 2007-05-05T02:00:00Z 55.9 -143. 331 2.80
#> 2 2007-05-05T02:10:00Z 55.9 -143. 328 2.60
#> 3 2007-05-05T02:20:00Z 55.9 -143. 329 2.20
#> 4 2007-05-05T02:30:00Z 55.9 -143. 356 2.10
#> 5 2007-05-05T02:40:00Z 55.9 -143. 360 1.5
#> 6 2007-05-05T02:50:00Z 55.9 -143. 10 1.90
#> 7 2007-05-05T03:00:00Z 55.9 -143. 10 2.20
#> 8 2007-05-05T03:10:00Z 55.9 -143. 14 2.20
#> 9 2007-05-05T03:20:00Z 55.9 -143. 16 2.10
#> 10 2007-05-05T03:30:00Z 55.9 -143. 22 1.60
#> # … with 33,476 more rows
Including year
buoy(dataset = 'cwind', buoyid = 41001, year = 1999)
#> Using c1999.nc
#> Dimensions (rows/cols): [52554 X 5]
#> 2 variables: [wind_dir, wind_spd]
#>
#> # A tibble: 52,554 x 5
#> time lat lon wind_dir wind_spd
#> <chr> <dbl> <dbl> <int> <dbl>
#> 1 1999-01-01T00:00:00Z 34.7 -72.7 272 11.7
#> 2 1999-01-01T00:10:00Z 34.7 -72.7 260 11
#> 3 1999-01-01T00:20:00Z 34.7 -72.7 249 8.70
#> 4 1999-01-01T00:30:00Z 34.7 -72.7 247 8.40
#> 5 1999-01-01T00:40:00Z 34.7 -72.7 240 7.10
#> 6 1999-01-01T00:50:00Z 34.7 -72.7 242 7.90
#> 7 1999-01-01T01:00:00Z 34.7 -72.7 246 8.30
#> 8 1999-01-01T01:10:00Z 34.7 -72.7 297 10.9
#> 9 1999-01-01T01:20:00Z 34.7 -72.7 299 11.3
#> 10 1999-01-01T01:30:00Z 34.7 -72.7 299 11.1
#> # … with 52,544 more rows
Including year and datatype
buoy(dataset = 'cwind', buoyid = 45005, year = 2008, datatype = "c")
#> Dimensions (rows/cols): [29688 X 5]
#> 2 variables: [wind_dir, wind_spd]
#>
#> # A tibble: 29,688 x 5
#> time lat lon wind_dir wind_spd
#> <chr> <dbl> <dbl> <int> <dbl>
#> 1 2008-04-29T09:00:00Z 41.7 -82.4 10 9
#> 2 2008-04-29T09:10:00Z 41.7 -82.4 8 9
#> 3 2008-04-29T09:20:00Z 41.7 -82.4 5 9.30
#> 4 2008-04-29T09:30:00Z 41.7 -82.4 13 9.5
#> 5 2008-04-29T09:40:00Z 41.7 -82.4 14 9.40
#> 6 2008-04-29T09:50:00Z 41.7 -82.4 12 9.40
#> 7 2008-04-29T14:00:00Z 41.7 -82.4 341 6.5
#> 8 2008-04-29T14:10:00Z 41.7 -82.4 332 6.80
#> 9 2008-04-29T14:20:00Z 41.7 -82.4 335 6.40
#> 10 2008-04-29T14:30:00Z 41.7 -82.4 332 6.5
#> # … with 29,678 more rows
Including just datatype
buoy(dataset = 'cwind', buoyid = 45005, datatype = "c")
#> Using c1996.nc
#> Dimensions (rows/cols): [26784 X 5]
#> 2 variables: [wind_dir, wind_spd]
#>
#> # A tibble: 26,784 x 5
#> time lat lon wind_dir wind_spd
#> <chr> <dbl> <dbl> <int> <dbl>
#> 1 1996-05-15T23:00:00Z 41.7 -82.4 337 2.20
#> 2 1996-05-15T23:10:00Z 41.7 -82.4 282 1
#> 3 1996-05-15T23:20:00Z 41.7 -82.4 282 2.20
#> 4 1996-05-15T23:30:00Z 41.7 -82.4 258 2.60
#> 5 1996-05-15T23:40:00Z 41.7 -82.4 254 3
#> 6 1996-05-15T23:50:00Z 41.7 -82.4 252 2.70
#> 7 1996-05-16T00:00:00Z 41.7 -82.4 240 2.10
#> 8 1996-05-16T00:10:00Z 41.7 -82.4 246 2.40
#> 9 1996-05-16T00:20:00Z 41.7 -82.4 251 2.70
#> 10 1996-05-16T00:30:00Z 41.7 -82.4 253 2.90
#> # … with 26,774 more rows