View source: R/weatherHelper.R
read.noaa | R Documentation |
Queries NOAA's Web Services according to the following documentation: http://www.ncdc.noaa.gov/cdo-web/webservices/v2.
read.noaa(table, param = NULL, quietly = TRUE)
table |
the data table to query from, examples include "locations", "stations", "data" |
param |
extra parameters for the search |
To use this function you need to get a key for NOAA's API. This is free and you can generate one here: https://www.ncdc.noaa.gov/cdo-web/token. All weather functions in rterm look for an object in the global environment called "noaa_key". You can deal with this by taking the following line:
noaa_key <- "your_key_here"
and placing it either before the library(rterm) statement, or, preferably, in a .Rprofile that gets run when you load R. http://www.statmethods.net/interface/customizing.html
By default the queries return only 25 entries with a maximum limit of 1000, so be mindful that often much of what you thought you were querying is not returned.
read.ghcn
# Show available datasets read.noaa("datasets") # Show available data types of category "TEMP" read.noaa("datatypes", "datacategoryid=TEMP&limit=100") # Show locations for the location category of US State read.noaa("locations", "locationcategoryid=ST&limit=51") # Show Stations in Washington State recording Temperature GHCN # daily datasets since 2010 tmp <- read.noaa("stations", paste("locationid=FIPS:53", "datacategoryid=TEMP", "datasetid=GHCND", "startdate=2010-01-01", "limit=1000", sep = "&"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.