Skip to contents

Make a request to the /climatedata/climatestationts endpoints to retrieve daily or monthly (climatestationtsday or climatestationtsmonth)climate station time series data by station number or Site IDs within a given date range (start and end dates)

Usage

get_climate_ts(
  station_number = NULL,
  site_id = NULL,
  param = NULL,
  start_date = "1900-01-01",
  end_date = Sys.Date(),
  timescale = NULL,
  api_key = NULL
)

Arguments

station_number

character, surface water station number

site_id

character vector or list of characters of climate station site IDs

param

character climate variable. One of: "Evap", "FrostDate", "MaxTemp", "MeanTemp", "MinTemp", "Precip", "Snow", "SnowDepth", "SnowSWE", "Solar","VP", "Wind"

start_date

character date to request data start point YYYY-MM-DD. Default is start date is "1900-01-01".

end_date

character date to request data end point YYYY-MM-DD. Default end date is the current date the function is run.

timescale

character indicating the time series time step. Either "day", "month", "year". Default is to return daily time series.

api_key

character, API authorization token, optional. If more than maximum number of requests per day is desired, an API key can be obtained from CDSS.

Value

dataframe of climate station timeseries data

Examples

if (FALSE) {
# Retrieve daily maximum temperatures
daily_maxtemp <- get_climate_ts(
  site_id     = "USC00055984",
  param       = "MaxTemp",
  start_date  = "2017-01-01",
  end_date    = "2020-01-01",
  timescale   = "day"
  )

# plot daily maximum temp at climate station
plot(daily_maxtemp$value~daily_maxtemp$datetime, type = "l")

# Retrieve monthly precipitation
monthly_precip <- get_climate_ts(
  site_id     = "USC00055984",
  param       = "Precip",
  start_date  = "2000-01-01",
  end_date    = "2022-01-01",
  timescale   = "month"
   )

 # plot daily max temp at climate station
 plot(monthly_precip$avg_value~monthly_precip$datetime, type = "l")
 }