climateR
An R 📦 for getting point and gridded climate data by AOI
Science Score: 33.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
â—‹CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
â—‹.zenodo.json file
-
â—‹DOI references
-
✓Academic publication links
Links to: zenodo.org -
✓Committers with academic emails
3 of 9 committers (33.3%) from academic institutions -
â—‹Institutional organization owner
-
â—‹JOSS paper metadata
-
â—‹Scientific vocabulary similarity
Low similarity (21.4%) to scientific vocabulary
Keywords
aoi
climate
dataset
geospatial
gridded-climate-data
rstats
weather
Keywords from Contributors
earth-system-model
Last synced: 11 months ago
·
JSON representation
Repository
An R 📦 for getting point and gridded climate data by AOI
Basic Info
- Host: GitHub
- Owner: mikejohnson51
- License: other
- Language: R
- Default Branch: master
- Homepage: https://mikejohnson51.github.io/climateR/
- Size: 67.8 MB
Statistics
- Stars: 195
- Watchers: 7
- Forks: 41
- Open Issues: 17
- Releases: 3
Topics
aoi
climate
dataset
geospatial
gridded-climate-data
rstats
weather
Created over 7 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%",
dev = "jpeg",
warning = FALSE,
message = FALSE
)
library(AOI)
library(dplyr)
library(ggplot2)
library(tidyterra)
library(scales) # Additional library for labels
```
# Welcome!
[](https://zenodo.org/badge/latestdoi/158620263)
[](https://github.com/mikejohnson51/climateR/actions/workflows/R-CMD-check.yaml)
[](#)
[](https://choosealicense.com/licenses/mit/)
[](https://www.repostatus.org/#active)
[](https://codecov.io/gh/mikejohnson51/climateR)
`climateR` simplifies the steps needed to get gridded geospatial data into R. At its core, it provides three main things:
1. A catalog of `r nrow(climateR::catalog)` geospatial climate, land cover, and soils resources from `r length(unique(climateR::catalog$id))` collections. See (`climateR::catalog`)
This catalog is an [evolving, federated collection of datasets](https://github.com/mikejohnson51/climateR-catalogs) that can be accessed by the data access utilities. This resource is rebuilt automatically on a monthly cycle to ensure the data provided is accurate, while continuously growing based on user requests.
2. A general [toolkit for accessing remote and local gridded data](https://mikejohnson51.github.io/climateR/reference/index.html#data-access) files bounded by space, time, and variable constraints (`dap`, `dap_crop`, `read_dap_file`)
3. A set of [shortcuts](https://mikejohnson51.github.io/climateR/reference/index.html#shortcuts) that implement these methods for a core set of selected catalog elements
> :warning: **Python Users**: Data catalog access is available through the USGS [`gdptools`](https://gdptools.readthedocs.io/en/latest/) package. Directly analogous climateR functionality can be found in [`climatePy`](https://github.com/LynkerIntel/climatePy)
# Installation
```{r, eval = FALSE }
remotes::install_github("mikejohnson51/AOI") # suggested!
remotes::install_github("mikejohnson51/climateR")
```
```{r}
library(climateR)
```
# Basic Usage
The examples used here call upon the following shortcuts:
- `getGridMET` (OPeNDAP server, historic data)
- `getMODIS` (Authenticated OPeNDAP server)
- `getMACA` (OPeNDAP server, projection data)
- `getNLCD` (COG)
- `get3DEP` (VRT)
- `getCHIRPS` (erddap)
With the aim of highlighting the convenience of a consistent access patterns for a variety of data stores.
### Defining Areas/Points of Interest
`climateR` is designed with the same concepts as `AOI`. Namely, that all spatial data aggregation questions must start with an extent/area of interest.
Before extracting any data, you must provide an. For the examples here, we will use the state of Colorado (polygons), and all of its cities (points).
```{r}
colorado = aoi_get(state = "CO", county = "all")
cities = readRDS(system.file("co/cities_colorado.rds", package = "climateR"))
```
```{r, echo = FALSE}
ggplot() +
geom_sf(data = colorado) +
geom_sf(data = cities, size = .5) +
geom_sf(data = filter(cities, NAME == "FORT COLLINS"), color = "red", pch = 8, size = 2) +
theme_void() +
labs(title = "Colorado Counties and cities",
subtitle = "Fort Collins is in red")
```
## Extent extraction
The default behavior of `climateR` is to request data for the extent of the AOI passed regardless of whether it is `POINT` or `POLYGON` data.
The _exception_ to the default behavior is if the the AOI is a single point. To illustrate:
#### POLYGON(s) act as a single extent
```{r}
# Request Data for Colorado (POLYGON(s))
system.time({
gridmet_pr = getGridMET(AOI = colorado,
varname = "pr",
startDate = "1991-10-29",
endDate = "1991-11-06")
})
```
```{r,echo = FALSE}
ggplot() +
geom_spatraster(data = gridmet_pr$precipitation_amount) +
facet_wrap(~lyr) +
scale_fill_hypso_c(
palette = "colombia_bathy",
labels = label_number(suffix = "mm"),
n.breaks = 12,
guide = guide_legend(reverse = TRUE)
) +
labs(
fill = "",
title = "Gridmet Rainfall for Colorado",
subtitle = "1991-10-29 / 1991-11-03"
) +
theme_void()
```
#### POINTS(s) act as a single extent
```{r}
# Request data using cities (POINTs)
pr = getGridMET(
AOI = cities,
varname = "pr",
startDate = "2020-10-29")
```
```{r, echo = FALSE}
ggplot() +
geom_spatraster(data = pr$precipitation_amount) +
geom_spatvector(data = cities, color = "black", fill = NA, size = .01) +
facet_wrap(~lyr) +
scale_fill_hypso_c(
palette = "dem_print",
labels = label_number(suffix = "kg/m^2/yr"),
n.breaks = 12,
guide = guide_legend(reverse = TRUE)
) +
labs(
fill = "",
title = "MODIS PET for Colorado",
subtitle = "2020-10-29"
) +
theme_void()
```
#### Single POINT(s) act as an extent
However since the extent of a POINT means `{xmax = xmin}` and `{ymax = ymin}`, climateR will return a time series of the intersecting cell, opposed to a one cell `SpatRaster`.
```{r}
# Request data for a single city
system.time({
future_city = getMACA(AOI = cities[1,],
varname = "tasmax",
startDate = "2050-10-29",
endDate = "2050-11-06")
})
```
```{r}
future_city
```
#### Dynamic AOIs, tidyverse piping
All `climateR` functions treat the extent of the AOI and the default extraction area. This allows multiple climateR shortcuts to be chained together using either the base R or dplyr piping syntax.
```{r}
pipes = aoi_ext("Fort Collins", wh = c(10, 20), units = "km", bbox = TRUE)|>
getNLCD() |>
getTerraClimNormals(varname = c("tmax", "ppt"))
lapply(pipes, dim)
```
### Extract timeseries from exisitng objects:
Using `extract_sites`, you can pass an existing data object. If no identified column is provided to name the extracted timeseries, the first, fully unique column in the data.frame is used:
```{r}
gridmet_pts = extract_sites(gridmet_pr, pts = cities)
names(gridmet_pts)[1:5]
gridmet_pts = extract_sites(gridmet_pr, pts = cities, ID = 'NAME')
names(gridmet_pts)[1:5]
```
# Unit Based Extraction
While the default behavior is to extract data by **extent**, there are cases when the input AOI is a set of discrete units that you _want_ to act as discrete units.
- A set of `POINT`s from which to extract time series
- A set of `POLYGON`s that data should be summarized to (mean, max, min, etc.) (**WIP**)
In `climateR`, populating the `ID` parameter of any shortcut (or `dap`) function, triggers data to be extracted by unit.
### Extact timeseries for POINTs
In the `cities` object, the individual `POINT`s are uniquely identified by a `NAME` column. Tellings a climateR function, that `ID = "NAME"` triggers it to return the summary:
```{r}
chirps_pts = getCHIRPS(AOI = cities,
varname = "precip",
startDate = "1991-10-29",
endDate = "1991-11-06",
ID = "NAME")
dim(chirps_pts)
names(chirps_pts)[1:5]
```
```{r, echo = F}
ggplot() +
geom_point(data = gridmet_pts, aes(x = date, y = FORTCOLLINS, col = "gridmet")) +
geom_line(data = gridmet_pts, aes(x = date, y = FORTCOLLINS, col = "gridmet")) +
geom_point(data = chirps_pts, aes(x = date, y = FORTCOLLINS, col = "CHIRPS")) +
geom_line(data = chirps_pts, aes(x = date, y = FORTCOLLINS, col = "CHIRPS")) +
theme_minimal() +
labs(title = "Comparative Rainfall in Fort Collins",
subtitle = "1991-10-29 / 1991-11-03",
color = "Model",
y = "Rainfall (mm)",
x = "Date")
```
### Integration with `zonal`
While climateR does not yet provide areal summaries, our intention is to integrate the functionality from `zonal`. Until then, `climateR` outputs can be piped directly into `execute_zonal`. The zonal package also requires a uniquely identifying column name, and a function to summarize data with.
```{r}
library(zonal)
system.time({
chirps = getCHIRPS(AOI = colorado,
varname = "precip",
startDate = "1991-10-29",
endDate = "1991-11-06") %>%
execute_zonal(geom = colorado,
fun = "max",
ID = "fip_code")
})
```
```{r, echo = FALSE}
plot(chirps[grepl("precip_", names(chirps))])
```
## Basic Animation
### Gridded
```{r, eval = FALSE}
animation(gridmet_pr$precipitation_amount, AOI = AOI, outfile = "man/figures/rast_gif.gif")
```
```{r, echo = FALSE}
knitr::include_graphics("man/figures/rast_gif.gif")
```
### Polygon
```{r, eval = FALSE}
animation(max, feild_pattern = "precip_", outfile = "man/figures/vect_gif.gif")
```
```{r, echo = FALSE}
knitr::include_graphics("man/figures/vect_gif.gif")
```
Owner
- Name: MikeJohnson-NOAA
- Login: mikejohnson51
- Kind: user
- Location: Fort Collins, CO
- Company: @lynker-spatial, @NOAA-OWP
- Website: http://mikejohnson51.github.io
- Repositories: 134
- Profile: https://github.com/mikejohnson51
Geography | Data Science | Water Resources
GitHub Events
Total
- Issues event: 6
- Watch event: 22
- Issue comment event: 6
- Push event: 7
- Pull request event: 2
Last Year
- Issues event: 6
- Watch event: 22
- Issue comment event: 6
- Push event: 7
- Pull request event: 2
Committers
Last synced: 12 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| mikejohnson51 | j****0@u****u | 127 |
| mikejohnson51 | m****n@g****u | 44 |
| program-- | j****n@j****e | 7 |
| arashmodrad | a****d@u****u | 3 |
| Max Joseph | m****h@g****m | 1 |
| James Tsakalos | 7****s | 1 |
| Eric R Scott | s****r@g****m | 1 |
| nayhur | n****r@l****m | 1 |
| anguswg-ucsb | a****s@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 96
- Total pull requests: 13
- Average time to close issues: 5 months
- Average time to close pull requests: 1 day
- Total issue authors: 53
- Total pull request authors: 8
- Average comments per issue: 3.07
- Average comments per pull request: 0.31
- Merged pull requests: 11
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 9
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 1 minute
- Issue authors: 8
- Pull request authors: 1
- Average comments per issue: 0.67
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- mikejohnson51 (18)
- rsmiller74 (8)
- Heed725 (6)
- anguswg-ucsb (4)
- mbjoseph (3)
- urskalbitzer (3)
- dblodgett-usgs (2)
- sienna-templeman (2)
- pjgoodling (2)
- meaghanregina (2)
- BaxW (2)
- eli-asarian (2)
- Rapsodia86 (2)
- ldecicco-USGS (2)
- tjsamo (1)
Pull Request Authors
- program-- (6)
- arashmodrad (2)
- anguswg-ucsb (1)
- mbjoseph (1)
- jamestsakalos (1)
- Aariq (1)
- nayhur (1)
- mikejohnson51 (1)
Top Labels
Issue Labels
question (5)
enhancement (4)
bug (2)
help wanted (1)
Pull Request Labels
Packages
- Total packages: 2
- Total downloads: unknown
-
Total dependent packages: 0
(may contain duplicates) -
Total dependent repositories: 0
(may contain duplicates) - Total versions: 6
proxy.golang.org: github.com/mikejohnson51/climateR
- Documentation: https://pkg.go.dev/github.com/mikejohnson51/climateR#section-documentation
- License: other
-
Latest release: v0.3.2
published over 2 years ago
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
11 months ago
proxy.golang.org: github.com/mikejohnson51/climater
- Documentation: https://pkg.go.dev/github.com/mikejohnson51/climater#section-documentation
- License: other
-
Latest release: v0.3.2
published over 2 years ago
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
11 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.5.0 depends
- RNetCDF * imports
- doParallel * imports
- foreach * imports
- httr * imports
- methods * imports
- parallel * imports
- raster * imports
- sf * imports
.github/workflows/R-CMD-check.yaml
actions
- actions/checkout v2 composite
- actions/upload-artifact master composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite