Name: rnoaa
Owner: rOpenSci
Description: R interface to many NOAA data APIs
Created: 2013-07-08 22:31:24.0
Updated: 2018-01-09 18:54:43.0
Pushed: 2018-01-08 15:18:26.0
Homepage: https://ropensci.org/tutorials/rnoaa_tutorial.html
Size: 102067
Language: R
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
rnoaa
is an R interface to many NOAA data sources. We don't cover all of them, but we include many commonly used sources, and add we are always adding new sources. We focus on easy to use interfaces for getting NOAA data, and giving back data in easy to use formats downstream. We currently don't do much in the way of plots or analysis.
There is a tutorial on the rOpenSci website, and there are many tutorials in the package itself, available in your R session, or on CRAN. The tutorials:
Functions to work with buoy data use netcdf files. You'll need the ncdf
package for those functions, and those only. ncdf
is in Suggests in this package, meaning you only need ncdf
if you are using the buoy functions. You'll get an informative error telling you to install ncdf
if you don't have it and you try to use the buoy functions. Installation of ncdf
should be straightforward on Mac and Windows, but on Linux you may have issues. See http://cran.r-project.org/web/packages/ncdf/INSTALL
There are many NOAA NCDC datasets. All data sources work, except NEXRAD2
and NEXRAD3
, for an unknown reason. This relates to ncdc_*()
functions only.
|Dataset |Description |Start Date |End Date | Data Coverage| |:———-|:—————————|:———-|:———-|————-:| |GHCND |Daily Summaries |1763-01-01 |2017-05-01 | 1.00| |GSOM |Global Summary of the Month |1763-01-01 |2017-04-01 | 1.00| |GSOY |Global Summary of the Year |1763-01-01 |2016-01-01 | 1.00| |NEXRAD2 |Weather Radar (Level II) |1991-06-05 |2017-05-01 | 0.95| |NEXRAD3 |Weather Radar (Level III) |1994-05-20 |2017-04-07 | 0.95| |NORMAL_ANN |Normals Annual/Seasonal |2010-01-01 |2010-01-01 | 1.00| |NORMAL_DLY |Normals Daily |2010-01-01 |2010-12-31 | 1.00| |NORMAL_HLY |Normals Hourly |2010-01-01 |2010-12-31 | 1.00| |NORMAL_MLY |Normals Monthly |2010-01-01 |2010-12-01 | 1.00| |PRECIP_15 |Precipitation 15 Minute |1970-05-12 |2014-01-01 | 0.25| |PRECIP_HLY |Precipitation Hourly |1900-01-01 |2014-01-01 | 1.00|
Each NOAA dataset has a different set of attributes that you can potentially get back in your search. See http://www.ncdc.noaa.gov/cdo-web/datasets for detailed info on each dataset. We provide some information on the attributes in this package; see the vignette for attributes to find out more
You'll need an API key to use the NOAA NCDC functions (those starting with ncdc*()
) in this package (essentially a password). Go to http://www.ncdc.noaa.gov/cdo-web/token to get one. You can't use this package without an API key.
Once you obtain a key, there are two ways to use it.
a) Pass it inline with each function call (somewhat cumbersome)
(datasetid = 'PRECIP_HLY', locationid = 'ZIP:28801', datatypeid = 'HPCP', limit = 5, token = "YOUR_TOKEN")
b) Alternatively, you might find it easier to set this as an option, either by adding this line to the top of a script or somewhere in your .rprofile
ons(noaakey = "KEY_EMAILED_TO_YOU")
c) You can always store in permamently in your .Rprofile
file.
GDAL
You'll need GDAL installed first. You may want to use GDAL >= 0.9-1
since that version or later can read TopoJSON format files as well, which aren't required here, but may be useful. Install GDAL:
sudo apt-get install gdal-bin
referenceThen when you install the R package rgdal
(rgeos
also requires GDAL), you'll most likely need to specify where you're gdal-config
file is on your machine, as well as a few other things. I have an OSX Mavericks machine, and this works for me (there's no binary for Mavericks, so install the source version):
all.packages("http://cran.r-project.org/src/contrib/rgdal_0.9-1.tar.gz", repos = NULL, type="source", configure.args = "--with-gdal-config=/Library/Frameworks/GDAL.framework/Versions/1.10/unix/bin/gdal-config --with-proj-include=/Library/Frameworks/PROJ.framework/unix/include --with-proj-lib=/Library/Frameworks/PROJ.framework/unix/lib")
The rest of the installation should be easy. If not, let us know.
Stable version from CRAN
all.packages("rnoaa")
or development version from GitHub
ools::install_github("ropensci/rnoaa")
Load rnoaa
ary('rnoaa')
_locs(locationcategoryid='CITY', sortfield='name', sortorder='desc')
meta
meta$totalCount
1] 1980
meta$pageCount
1] 25
meta$offset
1] 1
data
mindate maxdate name datacoverage id
1892-08-01 2017-03-31 Zwolle, NL 1.0000 CITY:NL000012
1901-01-01 2017-04-29 Zurich, SZ 1.0000 CITY:SZ000007
1957-07-01 2017-04-29 Zonguldak, TU 1.0000 CITY:TU000057
1906-01-01 2017-04-29 Zinder, NG 0.9025 CITY:NG000004
1973-01-01 2017-04-29 Ziguinchor, SG 1.0000 CITY:SG000004
1938-01-01 2017-04-29 Zhytomyra, UP 0.9723 CITY:UP000025
1948-03-01 2017-04-29 Zhezkazgan, KZ 0.9302 CITY:KZ000017
1951-01-01 2017-04-29 Zhengzhou, CH 1.0000 CITY:CH000045
1941-01-01 2017-03-31 Zaragoza, SP 1.0000 CITY:SP000021
0 1936-01-01 2009-06-17 Zaporiyhzhya, UP 1.0000 CITY:UP000024
1 1957-01-01 2017-04-29 Zanzibar, TZ 0.8016 CITY:TZ000019
2 1973-01-01 2017-04-29 Zanjan, IR 0.9105 CITY:IR000020
3 1893-01-01 2017-05-01 Zanesville, OH US 1.0000 CITY:US390029
4 1912-01-01 2017-04-29 Zahle, LE 0.9819 CITY:LE000004
5 1951-01-01 2017-04-29 Zahedan, IR 0.9975 CITY:IR000019
6 1860-12-01 2017-04-29 Zagreb, HR 1.0000 CITY:HR000002
7 1975-08-29 2017-04-29 Zacatecas, MX 0.9306 CITY:MX000036
8 1947-01-01 2017-04-29 Yuzhno-Sakhalinsk, RS 1.0000 CITY:RS000081
9 1893-01-01 2017-05-01 Yuma, AZ US 1.0000 CITY:US040015
0 1942-02-01 2017-05-01 Yucca Valley, CA US 1.0000 CITY:US060048
1 1885-01-01 2017-05-01 Yuba City, CA US 1.0000 CITY:US060047
2 1998-02-01 2017-04-29 Yozgat, TU 1.0000 CITY:TU000056
3 1893-01-01 2017-05-01 Youngstown, OH US 1.0000 CITY:US390028
4 1894-01-01 2017-05-01 York, PA US 1.0000 CITY:US420024
5 1869-01-01 2017-05-01 Yonkers, NY US 1.0000 CITY:US360031
ttr(,"class")
1] "ncdc_locs"
_stations(datasetid='GHCND', locationid='FIPS:12017', stationid='GHCND:USC00084289')
meta
ULL
data
elevation mindate maxdate latitude name
12.2 1899-02-01 2017-04-30 28.8029 INVERNESS 3 SE, FL US
datacoverage id elevationUnit longitude
1 GHCND:USC00084289 METERS -82.3126
ttr(,"class")
1] "ncdc_stations"
<- ncdc(datasetid='NORMAL_DLY', stationid='GHCND:USW00014895', datatypeid='dly-tmax-normal', startdate = '2010-05-01', enddate = '2010-05-10')
( out$data )
date datatype station value fl_c
2010-05-01T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 652 S
2010-05-02T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 655 S
2010-05-03T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 658 S
2010-05-04T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 661 S
2010-05-05T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 663 S
2010-05-06T00:00:00 DLY-TMAX-NORMAL GHCND:USW00014895 666 S
<- ncdc(datasetid='GHCND', stationid='GHCND:USW00014895', datatypeid='PRCP', startdate = '2010-05-01', enddate = '2010-10-31', limit=500)
_plot(out, breaks="1 month", dateformat="%d/%m")
You can pass many outputs from calls to the noaa
function in to the ncdc_plot
function.
<- ncdc(datasetid='GHCND', stationid='GHCND:USW00014895', datatypeid='PRCP', startdate = '2010-03-01', enddate = '2010-05-31', limit=500)
<- ncdc(datasetid='GHCND', stationid='GHCND:USW00014895', datatypeid='PRCP', startdate = '2010-09-01', enddate = '2010-10-31', limit=500)
_plot(out1, out2, breaks="45 days")
_datasets()
meta
meta$offset
1] 1
meta$count
1] 11
meta$limit
1] 25
data
uid mindate maxdate name
gov.noaa.ncdc:C00861 1763-01-01 2017-05-01 Daily Summaries
gov.noaa.ncdc:C00946 1763-01-01 2017-04-01 Global Summary of the Month
gov.noaa.ncdc:C00947 1763-01-01 2016-01-01 Global Summary of the Year
gov.noaa.ncdc:C00345 1991-06-05 2017-05-01 Weather Radar (Level II)
gov.noaa.ncdc:C00708 1994-05-20 2017-04-07 Weather Radar (Level III)
gov.noaa.ncdc:C00821 2010-01-01 2010-01-01 Normals Annual/Seasonal
gov.noaa.ncdc:C00823 2010-01-01 2010-12-31 Normals Daily
gov.noaa.ncdc:C00824 2010-01-01 2010-12-31 Normals Hourly
gov.noaa.ncdc:C00822 2010-01-01 2010-12-01 Normals Monthly
0 gov.noaa.ncdc:C00505 1970-05-12 2014-01-01 Precipitation 15 Minute
1 gov.noaa.ncdc:C00313 1900-01-01 2014-01-01 Precipitation Hourly
datacoverage id
1.00 GHCND
1.00 GSOM
1.00 GSOY
0.95 NEXRAD2
0.95 NEXRAD3
1.00 NORMAL_ANN
1.00 NORMAL_DLY
1.00 NORMAL_HLY
1.00 NORMAL_MLY
0 0.25 PRECIP_15
1 1.00 PRECIP_HLY
ttr(,"class")
1] "ncdc_datasets"
_datacats(locationid = 'CITY:US390029')
meta
meta$totalCount
1] 38
meta$pageCount
1] 25
meta$offset
1] 1
data
name id
Annual Agricultural ANNAGR
Annual Degree Days ANNDD
Annual Precipitation ANNPRCP
Annual Temperature ANNTEMP
Autumn Agricultural AUAGR
Autumn Degree Days AUDD
Autumn Precipitation AUPRCP
Autumn Temperature AUTEMP
Computed COMP
0 Computed Agricultural COMPAGR
1 Degree Days DD
2 Dual-Pol Moments DUALPOLMOMENT
3 Echo Tops ECHOTOP
4 Hydrometeor Type HYDROMETEOR
5 Miscellany MISC
6 Other OTHER
7 Overlay OVERLAY
8 Precipitation PRCP
9 Reflectivity REFLECTIVITY
0 Sky cover & clouds SKY
1 Spring Agricultural SPAGR
2 Spring Degree Days SPDD
3 Spring Precipitation SPPRCP
4 Spring Temperature SPTEMP
5 Summer Agricultural SUAGR
ttr(,"class")
1] "ncdc_datacats"
The function tornadoes()
simply gets all the data. So the call takes a while, but once done, is fun to play with.
<- tornadoes()
GR data source with driver: ESRI Shapefile
ource: "/Users/sacmac/Library/Caches/rnoaa/tornadoes/torn", layer: "torn"
ith 60114 features
t has 22 fields
nteger64 fields read as strings: om yr mo dy tz stf stn mag inj fat wid fc
ary('sp')
(shp)
In this example, search for metadata for a single station ID
(qid = 'COOP:046742')
`20002078`
`20002078`$id
1] "20002078"
`20002078`$head
preferredName latitude_dec longitude_dec precision
PASO ROBLES MUNICIPAL AP, CA 35.6697 -120.6283 DDddddd
por.beginDate por.endDate
1949-10-05T00:00:00.000 Present
`20002078`$namez
name nameType
PASO ROBLES MUNICIPAL AP COOP
PASO ROBLES MUNICIPAL AP PRINCIPAL
PASO ROBLES MUNICIPAL ARPT PUB
`20002078`$identifiers
idType id
GHCND USW00093209
GHCNMLT USW00093209
Get storm data for the year 2010
m_data(year = 2010)
A tibble: 2,855 × 195
serial_num season num basin sub_basin name iso_time
<chr> <int> <int> <chr> <chr> <chr> <chr>
2009317S10073 2010 1 SI MM ANJA 2009-11-13 06:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-13 12:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-13 18:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-14 00:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-14 06:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-14 12:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-14 18:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-15 00:00:00
2009317S10073 2010 1 SI MM ANJA 2009-11-15 06:00:00
0 2009317S10073 2010 1 SI MM ANJA 2009-11-15 12:00:00
... with 2,845 more rows, and 188 more variables: nature <chr>,
latitude <dbl>, longitude <dbl>, wind.wmo. <dbl>, pres.wmo. <dbl>,
center <chr>, wind.wmo..percentile <dbl>, pres.wmo..percentile <dbl>,
track_type <chr>, latitude_for_mapping <dbl>,
longitude_for_mapping <dbl>, current.basin <chr>,
hurdat_atl_lat <dbl>, hurdat_atl_lon <dbl>, hurdat_atl_grade <dbl>,
hurdat_atl_wind <dbl>, hurdat_atl_pres <dbl>, td9636_lat <dbl>,
Get forecast for a certain variable.
<- gefs("Total_precipitation_surface_6_Hour_Accumulation_ens", lat = 46.28125, lon = -116.2188)
(res$data)
Total_precipitation_surface_6_Hour_Accumulation_ens lon lat ens time2
0 244 46 0 6
0 244 46 1 12
0 244 46 2 18
0 244 46 3 24
0 244 46 4 30
0 244 46 5 36
There are a suite of functions for Argo data, a few egs:
atial search - by bounding box
_search("coord", box = c(-40, 35, 3, 2))
me based search
_search("coord", yearmin = 2007, yearmax = 2009)
ta quality based search
_search("coord", pres_qc = "A", temp_qc = "A")
arch on partial float id number
_qwmo(qwmo = 49)
t data
(dac = "meds", id = 4900881, cycle = 127, dtype = "D")
Get daily mean water level data at Fairport, OH (9063053)
s_search(station_name = 9063053, begin_date = 20150927, end_date = 20150928,
product = "daily_mean", datum = "stnd", time_zone = "lst")
metadata
metadata$id
1] "9063053"
metadata$name
1] "Fairport"
metadata$lat
1] "41.7598"
metadata$lon
1] "-81.2811"
data
t v f
2015-09-27 174.430 0,0
2015-09-28 174.422 0,0
rnoaa
in R doing citation(package = 'rnoaa')