Title: | Interface to the CIMIS Web API |
---|---|
Description: | Connect to the California Irrigation Management Information System (CIMIS) Web API. See the CIMIS main page <https://cimis.water.ca.gov> and web API documentation <https://et.water.ca.gov> for more information. |
Authors: | Michael Koohafkan [aut, cre] |
Maintainer: | Michael Koohafkan <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.4-1 |
Built: | 2025-01-31 04:39:13 UTC |
Source: | https://github.com/mkoohafkan/cimir |
This package provides an R interface to the California Irrigation Management Information System (CIMIS) Web API. In order to use this package, you will need to create a CIMIS account and request a web services AppKey.
cimir uses the following options()
to configure behavior:
cimir.appkey
: The CIMIS AppKey to use for queries.
cimir.timeout
: The maximum time to wait for a response
from the CIMIS Web API.
Alternatively, the CIMIS App Key can be saved to an environment
variable CIMIS_APPKEY
.
Maintainer: Michael Koohafkan [email protected]
Useful links:
Convert the Compass direction labels to degrees.
cimis_compass_to_degrees(x)
cimis_compass_to_degrees(x)
x |
A vector of compass directions, i.e. the data item labels "DayWindNnw", "DayWindSse", etc. Recognized directions are North-northeast (NNE), East-northeast (ENE), East-southeast (ESE), South-southeast (SSE), South-southwest (SSW), West-southwest (WSW), West-northwest (WNW), and North-northwest (NNW). |
A numeric vector of degrees corresponding to the middle azimuth of the corresponding compass direction.
cimis_compass_to_degrees("day-wind-nne") cimis_compass_to_degrees(c("SSE", "SSW", "wsw", "Wnw", "nnw"))
cimis_compass_to_degrees("day-wind-nne") cimis_compass_to_degrees(c("SSE", "SSW", "wsw", "Wnw", "nnw"))
Query CIMIS data using the Web API.
cimis_data( targets, start.date, end.date, items, measure.unit = c("E", "M"), prioritize.SCS = TRUE )
cimis_data( targets, start.date, end.date, items, measure.unit = c("E", "M"), prioritize.SCS = TRUE )
targets |
geographies or weather stations of interest. This parameter may specify one or many stations, zip codes, coordinates, or street addresses; however, you are not allowed to mix values from different categories. This means the targets parameter must contain only stations, only zip codes, only coordinates, or only street addresses. You will receive an error if you attempt to mix different category types. The formats are accepted:
|
start.date |
Specifies the start date. The data format is
|
end.date |
Specifies the end date. The data format is
|
items |
specifies one or more comma-delimited data elements to
include in your response. See |
measure.unit |
The unit of measure may be either |
prioritize.SCS |
This parameter is relevant only when the
targets parameter contains zip code(s). If |
A tibble
object.
if(is_key_set()) { cimis_data(targets = 170, start.date = Sys.Date() - 4, end.date = Sys.Date() - 1) }
if(is_key_set()) { cimis_data(targets = 170, start.date = Sys.Date() - 4, end.date = Sys.Date() - 1) }
Convert decimal degrees to Compass direction.
cimis_degrees_to_compass(x)
cimis_degrees_to_compass(x)
x |
A vector of directions in decimal degrees. |
Degrees are labeled with their corresponding Primary InterCardinal compass direction, following the convention of the CIMIS daily wind data items.
A factor vector of compass directions.
cimis_degrees_to_compass(c(30, 83, 120, 140, 190, 240, 300, 330)) cimis_degrees_to_compass(cimis_compass_to_degrees(c("NNE", "ENE", "ESE", "SSE", "SSW", "WSW", "WNW", "NNW")))
cimis_degrees_to_compass(c(30, 83, 120, 140, 190, 240, 300, 330)) cimis_degrees_to_compass(cimis_compass_to_degrees(c("NNE", "ENE", "ESE", "SSE", "SSW", "WSW", "WNW", "NNW")))
List CIMIS data quality control flags.
cimis_flags(type = c("Severe", "Informative"), period = "Current")
cimis_flags(type = c("Severe", "Informative"), period = "Current")
type |
The type of data flag, i.e. |
period |
The Time period that data was collected, i.e., "Current" or "Former" (pre-1995). |
a dataframe of data flags.
CIMIS Data Overview - Quality Control
cimis_flags() cimis_flags("Informative") cimis_flags("Severe", period = "Former")
cimis_flags() cimis_flags("Informative") cimis_flags("Severe", period = "Former")
Format the latitude and longitude of station in Decimal Degrees (DD) or Hour Minutes Seconds (HMS).
cimis_format_location(d, format = c("DD", "HMS"))
cimis_format_location(d, format = c("DD", "HMS"))
d |
A data frame of CIMIS data results. |
format |
The format to use, either Decimal Degrees ( |
The data frame, with a new "Latitude"
and "Longitude"
columns replacing the "HmsLatitude"
and "HmsLongitude"
columns.
if(is_key_set()) { d = cimis_station(170) cimis_format_location(d, "DD") cimis_format_location(d, "HMS") }
if(is_key_set()) { d = cimis_station(170) cimis_format_location(d, "DD") cimis_format_location(d, "HMS") }
List CIMIS data items.
cimis_items(type = c("Daily", "Hourly"))
cimis_items(type = c("Daily", "Hourly"))
type |
The type of data item, i.e. |
a dataframe of data items.
cimis_items()
cimis_items()
Split a large CIMIS query into multiple smaller queries based on a time interval.
cimis_split_query(targets, start.date, end.date, items, max.records = 1750L)
cimis_split_query(targets, start.date, end.date, items, max.records = 1750L)
targets |
geographies or weather stations of interest. This parameter may specify one or many stations, zip codes, coordinates, or street addresses; however, you are not allowed to mix values from different categories. This means the targets parameter must contain only stations, only zip codes, only coordinates, or only street addresses. You will receive an error if you attempt to mix different category types. The formats are accepted:
|
start.date |
Specifies the start date. The data format is
|
end.date |
Specifies the end date. The data format is
|
items |
specifies one or more comma-delimited data elements to
include in your response. See |
max.records |
The maximum number of records returned by a query. The default value is the the maximum data limit allowed by the CIMIS Web API (1,750 records). |
Queries are not split by targets
or items
, i.e. each
resulting query will include all targets and items.
A data frame with columns "targets", "start.date", "end.date", and "items".
cimis_split_query(170, "2000-01-01", "2010-12-31", "day-air-tmp-avg") cimis_split_query(c(149, 170), "2018-01-01", "2018-12-31", c("day-air-tmp-avg", "hly-air-tmp", "hly-rel-hum"))
cimis_split_query(170, "2000-01-01", "2010-12-31", "day-air-tmp-avg") cimis_split_query(c(149, 170), "2018-01-01", "2018-12-31", c("day-air-tmp-avg", "hly-air-tmp", "hly-rel-hum"))
Query CIMIS station metadata.
cimis_station(station) cimis_spatial_zipcode(zipcode) cimis_zipcode(zipcode)
cimis_station(station) cimis_spatial_zipcode(zipcode) cimis_zipcode(zipcode)
station |
The station ID. If missing, metadata for all stations is returned. |
zipcode |
The (spatial) zip code. If missing, metadata for all stations is returned. |
A tibble
object.
if(is_key_set()) { cimis_station() cimis_zipcode() cimis_spatial_zipcode() }
if(is_key_set()) { cimis_station() cimis_zipcode() cimis_spatial_zipcode() }
Collapse The Date and Hour columns to a single DateTime Column.
cimis_to_datetime(d)
cimis_to_datetime(d)
d |
A data frame of CIMIS data results. |
According to the CIMIS Report FAQs, all CIMIS data is based on Pacific Standard Time (PST).
The data frame, with a new "Datetime"
column replacing
the "Date"
and "Hour"
columns.
if(is_key_set()) { d = cimis_data(targets = 170, start.date = Sys.Date() - 4, end.date = Sys.Date() - 1, items = "hly-air-tmp") cimis_to_datetime(d) }
if(is_key_set()) { d = cimis_data(targets = 170, start.date = Sys.Date() - 4, end.date = Sys.Date() - 1, items = "hly-air-tmp") cimis_to_datetime(d) }
Enter your CIMIS AppKey for web API data access.
set_key(key = NULL) remove_key() is_key_set()
set_key(key = NULL) remove_key() is_key_set()
key |
A CIMIS AppKey. |
## Not run: set_key("YOUR-APP-KEY") is_key_set() remove_key() ## End(Not run)
## Not run: set_key("YOUR-APP-KEY") is_key_set() remove_key() ## End(Not run)