Changes in rnoaa v0.2.0

[This article was first published on rOpenSci Blog - R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

We just released v0.2 of rnoaa. For details on the update, see the release notes. What follows are some notes on the more important changes.

Updating to v0.2

Install rnoaa from CRAN

install.packages("rnoaa")

or Github

devtools::install_github("ropensci/rnoaa")

Then load rnoaa

library("rnoaa")

UI changes

We changed almost all function names to have a more intuitive programmatic user interface (or UI).

  • We changed all noaa*() functions to ncdc*() – these work only with NOAA National Climatic Data Center (NCDC) data, so the ncdc name makes sense.
  • noaa_seaice() changed to seaice(), which works with NOAA sea ice data.
  • noaa_swdi() changed to swdi(), which works with data from the Severe Weather Data Inventory.

Two new data sources

ERDDAP

We added new functions to interact with NOAA ERDDAP data: erddap_info(), erddap_data(), and erddap_search(). As a quick example, let's search for data, get a dataset identifier, then get information on that dataset, then get the data.

Search for data

(out <- erddap_search(query='fish size'))

## 7 results, showing first 20 
##                                         title          dataset_id
## 1                          CalCOFI Fish Sizes    erdCalCOFIfshsiz
## 2                        CalCOFI Larvae Sizes    erdCalCOFIlrvsiz
## 3                                CalCOFI Tows      erdCalCOFItows
## 4     GLOBEC NEP MOCNESS Plankton (MOC1) Data       erdGlobecMoc1
## 5 GLOBEC NEP Vertical Plankton Tow (VPT) Data        erdGlobecVpt
## 6         CalCOFI Larvae Counts Positive Tows erdCalCOFIlrvcntpos
## 7  OBIS - ARGOS Satellite Tracking of Animals           aadcArgos

Using a datasetid, search for information on a datasetid

(id <- out$info$dataset_id[1])

## [1] "erdCalCOFIfshsiz"

erddap_info(datasetid=id)$variables

##           variable_name data_type           actual_range
## 1  calcofi_species_code       int               19, 1550
## 2           common_name    String                       
## 3                cruise    String                       
## 4           fish_1000m3     float                       
## 5            fish_count     float                       
## 6             fish_size     float                       
## 7              itis_tsn       int                       
## 8              latitude     float         32.515, 38.502
## 9                  line     float             46.6, 93.3
## 10            longitude     float        -128.5, -117.33
## 11         net_location    String                       
## 12             net_type    String                       
## 13       order_occupied       int                       
## 14       percent_sorted     float                       
## 15       sample_quality     float                       
## 16      scientific_name    String                       
## 17                 ship    String                       
## 18            ship_code    String                       
## 19 standard_haul_factor     float                       
## 20              station     float            28.0, 114.9
## 21                 time    double 9.94464E8, 9.9510582E8
## 22           tow_number       int                  2, 10
## 23             tow_type    String                       
## 24       volume_sampled     float

Get data from the dataset, sticking to three variables for brevity

dat <- erddap_data(datasetid = id, fields = c('latitude','longitude','scientific_name'))
head(dat)

##    latitude  longitude       scientific_name
## 2 35.038334 -120.88333 Microstomus pacificus
## 3  34.97167 -121.02333    Cyclothone signata
## 4  34.97167 -121.02333    Cyclothone signata
## 5  34.97167 -121.02333    Cyclothone signata
## 6  34.97167 -121.02333    Cyclothone signata
## 7  34.97167 -121.02333    Cyclothone signata

NROW(dat)

## [1] 20939

Buoys!

We added functions to get data from the NOAA data buoy center. Keep in mind you have to install an external library to R called netcdf, and an R pacakge called ncdf4. See the source package README for more help. Install the buoy branch from Github:

devtools::install_github("rnoaa", "ropensci", ref="buoy")
library('rnoaa')

(out <- buoy(dataset = 'pwind', buoyid = 41021))

Available buoys in pwind:
41001 41002 41004 41006 41008 41009 41010 41012 41013 41021 41022 41023 41025 41035 41036 41040 41041 41043 41044 41046 41047 41048 41049 42001 42002 42003 42007 42012 42019 42020 42035 42036 42038 42039 42040 42041 42054 42055 42056 42057 42058 42059 42060 42065 42otp 44004 44005 44007 44008 44009 44011 44013 44014 44017 44018 44020 44025 44027 44028 44065 44066 45001 45002 45003 45004 45005 45006 45007 45008 45011 45012 46001 46002 46003 46005 46006 46011 46012 46013 46014 46015 46022 46023 46025 46026 46027 46028 46029 46030 46035 46041 46042 46044 46045 46047 46050 46051 46053 46054 46059 46060 46061 46062 46063 46066 46069 46070 46071 46072 46073 46075 46076 46077 46078 46079 46080 46081 46082 46083 46084 46085 46086 46087 46088 46089 46106 46270 51000 51001 51002 51003 51004 51028 51100 51101 alsn6 amaa2 amps2 amps3 amps4 auga2 blia2 burl1 buzm3 caro3 cdrf1 chlv2 clkn7 csbf1 dbln6 desw1 disw3 dpia1 drfa2 dryf1 dsln7 ducn7 fbis1 ffia2 fila2 fpsn7 fwyf1 gbcl1 gdil1 glln6 iosn3 ktnf1 lkwf1 lmbv4 lonf1 lscm4 mdrm1 mism1 mlrf1 mpcl1 mrka2 nwpo3 ostf1 pila2 pilm4 plsf1 pota2 ptac1 ptat2 ptgc1 roam4 sacv4 sanf1 sauf1 sbio1 sgnw3 sgof1 sisw1 smkf1 spgf1 srst2 stdm4 svls1 tplm2 ttiw1 venf1 verv4 wpow1
Available files for buoy 41021:
p1996.nc

Dimensions: [rows 4797, cols 3]
3 variables: [gust_dir, gust_spd, gust_time]

   gust_dir gust_spd gust_time
1       153      1.3 827105820
2        87      2.0 827106720
3        52      2.5 827110320
4        85      7.1 827113920
5       119      5.7 827117520
6        78      3.3 827121120
7       147     22.1 827124720
8       348      2.5 827128320
9        74      0.5 827134980
10       92      0.6 827137920

out$metadata[1]

$gust_dir
$gust_dir$name
[1] "gust_dir"

$gust_dir$prec
[1] "int"

$gust_dir$units
[1] "degrees_true"

$gust_dir$longname
[1] "Gust Direction"

$gust_dir$missval
[1] 999

$gust_dir$hasAddOffset
[1] FALSE

$gust_dir$hasScaleFact
[1] FALSE

head(out$data); tail(out$data)

  gust_dir gust_spd gust_time
1      153      1.3 827105820
2       87      2.0 827106720
3       52      2.5 827110320
4       85      7.1 827113920
5      119      5.7 827117520
6       78      3.3 827121120
     gust_dir gust_spd gust_time
4792       33     16.6 848164800
4793       21     15.6 848168340
4794       10     14.8 848172660
4795       19     15.9 848176140
4796       19     15.5 848177640
4797       25     14.4 848181420

More help!

We've added new vignettes, including one for NCDC attributes, one for an example NCDC workflow, a Seaice vignette, an SWDI vignette, an ERDDAP vignette, and a vignette for NOAA buoy data. The buoy functions and vignette is only available on the Github buoy branch.

To leave a comment for the author, please follow the link and comment on their blog: rOpenSci Blog - R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)