An open API service indexing awesome lists of open source software.

https://github.com/andypicke/rcoagmet

API Wrapper for CoAgMet Weather Stations
https://github.com/andypicke/rcoagmet

api colorado r weather

Last synced: 2 months ago
JSON representation

API Wrapper for CoAgMet Weather Stations

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# rcoagmet

[![R-CMD-check](https://github.com/andypicke/rcoagmet/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/andypicke/rcoagmet/actions/workflows/R-CMD-check.yaml)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

The goal of [rcoagmet](https://github.com/andypicke/rcoagmet) is to provide functions for downloading data from [CoAgMet](https://coagmet.colostate.edu/) weather stations, using their [Data API](https://coagmet.colostate.edu/data/doc.html).

See also this [blog post](https://andypicke.quarto.pub/portfolio/posts/rcoagmet/rcoagmet.html) describing the package and showing some examples.

# Installation

You can install the development version of rcoagmet from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("andypicke/rcoagmet")
```

# Examples

## Download metadata for all CoAgMet stations:

```{r }
library(rcoagmet)

meta <- get_coagmet_meta()

head(meta)

```

## Download metadata for all Norther water stations:

```{r }

meta <- get_coagmet_meta(network = "nw")

head(meta)

```

## Get latest data from all CoAgMet stations:

```{r}

latest <- get_coagmet_data(station_id = "all", time_step = "latest")

head(latest)

```

## Find closest CoAgMet station to a given point:
```{r}

# coordinates for Denver
xlat <- 39.74
xlon <- -104.99

nearest_station <- find_closest_coagmet_station(xlat, xlon)

nearest_station

```

## Download data for one station:

```{r}

df <- get_coagmet_data(station_id = "den01")

head(df)

```

### Plot air temp:
```{r}

df |>
ggplot2::ggplot(ggplot2::aes(date_and_time, air_temp)) +
ggplot2::geom_line()

```

### Make an interactive plot of one variable with plotly:
```{r}

#plot_coagmet_plotly(df, "air_temp")

```