{"id":13948899,"url":"https://github.com/mikejohnson51/climateR","last_synced_at":"2025-07-20T11:30:27.003Z","repository":{"id":36746440,"uuid":"158620263","full_name":"mikejohnson51/climateR","owner":"mikejohnson51","description":"An R 📦   for getting point and gridded climate data by AOI","archived":false,"fork":false,"pushed_at":"2024-12-05T06:22:39.000Z","size":71046,"stargazers_count":192,"open_issues_count":16,"forks_count":41,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-07-09T00:42:24.954Z","etag":null,"topics":["aoi","climate","dataset","geospatial","gridded-climate-data","rstats","weather"],"latest_commit_sha":null,"homepage":"https://mikejohnson51.github.io/climateR/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikejohnson51.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-22T00:07:16.000Z","updated_at":"2025-06-06T21:44:58.000Z","dependencies_parsed_at":"2023-09-21T19:45:33.396Z","dependency_job_id":"2d18e1f2-51b2-4100-8f08-33f7e57ed4b1","html_url":"https://github.com/mikejohnson51/climateR","commit_stats":{"total_commits":186,"total_committers":9,"mean_commits":"20.666666666666668","dds":"0.31720430107526887","last_synced_commit":"718a8d0357e9249894fb4f6e922911042db47e79"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mikejohnson51/climateR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejohnson51%2FclimateR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejohnson51%2FclimateR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejohnson51%2FclimateR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejohnson51%2FclimateR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikejohnson51","download_url":"https://codeload.github.com/mikejohnson51/climateR/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikejohnson51%2FclimateR/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265024825,"owners_count":23699614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aoi","climate","dataset","geospatial","gridded-climate-data","rstats","weather"],"created_at":"2024-08-08T05:01:33.834Z","updated_at":"2025-07-20T11:30:26.994Z","avatar_url":"https://github.com/mikejohnson51.png","language":"R","funding_links":[],"categories":["Climate Change","R"],"sub_categories":["Climate Data Access and Visualization"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\",\n  dev = \"jpeg\",\n  warning = FALSE,\n  message = FALSE\n)\n\nlibrary(AOI)\nlibrary(dplyr)\nlibrary(ggplot2)\nlibrary(tidyterra)\nlibrary(scales) # Additional library for labels\n```\n\n# Welcome! \u003ca href=\"https://github.com/mikejohnson51/climateR\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\"/\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![DOI](https://zenodo.org/badge/158620263.svg)](https://zenodo.org/badge/latestdoi/158620263)\n[![R CMD Check](https://github.com/mikejohnson51/climateR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/mikejohnson51/climateR/actions/workflows/R-CMD-check.yaml)\n[![Dependencies](https://img.shields.io/badge/dependencies-7/25-orange?style=flat)](#)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://choosealicense.com/licenses/mit/)\n[![Project Status: Active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![codecov](https://codecov.io/gh/mikejohnson51/climateR/branch/master/graph/badge.svg?token=7zs6C91SDw)](https://codecov.io/gh/mikejohnson51/climateR)\n\u003c!-- badges: end --\u003e\n\n`climateR` simplifies the steps needed to get gridded geospatial data into R. At its core, it provides three main things:\n\n1. 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`)\n\nThis 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.\n\n2. 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`)\n\n3. 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\n\n\u003e :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)\n\n# Installation\n\n```{r, eval = FALSE }\nremotes::install_github(\"mikejohnson51/AOI\") # suggested!\nremotes::install_github(\"mikejohnson51/climateR\")\n```\n\n```{r}\nlibrary(climateR)\n```\n# Basic Usage\n\nThe examples used here call upon the following shortcuts:\n\n- `getGridMET` (OPeNDAP server, historic data)\n- `getMODIS`   (Authenticated OPeNDAP server)\n- `getMACA`    (OPeNDAP server, projection data)\n- `getNLCD`    (COG)\n- `get3DEP`    (VRT)\n- `getCHIRPS`  (erddap)\n\nWith the aim of highlighting the convenience of a consistent access patterns for a variety of data stores.\n\n### Defining Areas/Points of Interest\n\n`climateR` is designed with the same concepts as `AOI`. Namely, that all spatial data aggregation questions must start with an extent/area of interest.\n\nBefore 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).\n\n```{r}\ncolorado = aoi_get(state = \"CO\", county = \"all\")\n\ncities = readRDS(system.file(\"co/cities_colorado.rds\", package = \"climateR\"))\n```\n\n```{r, echo = FALSE}\nggplot() + \n  geom_sf(data = colorado) + \n  geom_sf(data = cities, size = .5)  + \n  geom_sf(data = filter(cities, NAME == \"FORT COLLINS\"), color = \"red\", pch = 8, size = 2) + \n  theme_void() + \n  labs(title = \"Colorado Counties and cities\", \n       subtitle = \"Fort Collins is in red\")\n```\n\n\n## Extent extraction\n\nThe default behavior of `climateR` is to request data for the extent of the AOI passed regardless of whether it is `POINT` or `POLYGON` data. \n\nThe _exception_ to the default behavior is if the the AOI is a single point. To illustrate:\n\n#### POLYGON(s) act as a single extent\n\n```{r}\n# Request Data for Colorado (POLYGON(s))\nsystem.time({\n  gridmet_pr = getGridMET(AOI = colorado,\n                 varname = \"pr\",\n                 startDate = \"1991-10-29\",\n                 endDate  = \"1991-11-06\")\n})\n```\n\n```{r,echo = FALSE}\nggplot() +\n  geom_spatraster(data = gridmet_pr$precipitation_amount) +\n  facet_wrap(~lyr) +\n  scale_fill_hypso_c(\n    palette = \"colombia_bathy\",\n    labels = label_number(suffix = \"mm\"),\n    n.breaks = 12,\n    guide = guide_legend(reverse = TRUE)\n  ) +\n  labs(\n    fill = \"\",\n    title = \"Gridmet Rainfall for Colorado\",\n    subtitle = \"1991-10-29 / 1991-11-03\"\n  ) + \n  theme_void()\n```\n\n#### POINTS(s) act as a single extent\n\n```{r}\n# Request data using cities (POINTs)\npr = getGridMET(\n    AOI       = cities,\n    varname   = \"pr\",\n    startDate = \"2020-10-29\")\n```\n\n\n```{r, echo = FALSE}\nggplot() +\n  geom_spatraster(data = pr$precipitation_amount) +\n  geom_spatvector(data = cities, color = \"black\", fill = NA, size = .01) +\n  facet_wrap(~lyr) +\n  scale_fill_hypso_c(\n    palette = \"dem_print\",\n    labels = label_number(suffix = \"kg/m^2/yr\"),\n    n.breaks = 12,\n    guide = guide_legend(reverse = TRUE)\n  ) +\n  labs(\n    fill = \"\",\n    title = \"MODIS PET for Colorado\",\n    subtitle = \"2020-10-29\"\n  ) +\n  theme_void()\n```\n\n#### Single POINT(s) act as an extent \n\nHowever 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`.\n\n```{r}\n# Request data for a single city\nsystem.time({\n  future_city = getMACA(AOI = cities[1,],\n                        varname = \"tasmax\",\n                        startDate = \"2050-10-29\",\n                        endDate  = \"2050-11-06\")\n})\n```\n\n```{r}\nfuture_city\n```\n\n\n#### Dynamic AOIs, tidyverse piping\n\nAll `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.\n\n```{r}\npipes = aoi_ext(\"Fort Collins\", wh = c(10, 20), units = \"km\", bbox = TRUE)|\u003e\n  getNLCD() |\u003e\n  getTerraClimNormals(varname = c(\"tmax\", \"ppt\"))\n\nlapply(pipes, dim)\n```\n\n### Extract timeseries from exisitng objects:\n\nUsing `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:\n\n```{r}\ngridmet_pts = extract_sites(gridmet_pr, pts = cities)\nnames(gridmet_pts)[1:5]\n\ngridmet_pts = extract_sites(gridmet_pr, pts = cities, ID = 'NAME')\nnames(gridmet_pts)[1:5]\n```\n\n# Unit Based Extraction\n\nWhile 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.\n\n- A set of `POINT`s from which to extract time series\n- A set of `POLYGON`s that data should be summarized to (mean, max, min, etc.) (**WIP**)\n\nIn `climateR`, populating the `ID` parameter of any shortcut (or `dap`) function, triggers data to be extracted by unit. \n\n### Extact timeseries for POINTs\n\nIn 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:\n\n```{r}\nchirps_pts = getCHIRPS(AOI = cities,\n                       varname = \"precip\",\n                       startDate = \"1991-10-29\",\n                       endDate  = \"1991-11-06\",\n                       ID = \"NAME\")\n\ndim(chirps_pts)\nnames(chirps_pts)[1:5]\n```\n\n```{r, echo = F}\nggplot() + \n  geom_point(data = gridmet_pts, aes(x = date, y = FORTCOLLINS, col = \"gridmet\")) + \n  geom_line(data = gridmet_pts, aes(x = date, y = FORTCOLLINS, col = \"gridmet\")) + \n  geom_point(data = chirps_pts, aes(x = date, y = FORTCOLLINS, col = \"CHIRPS\")) +\n  geom_line(data = chirps_pts, aes(x = date, y = FORTCOLLINS, col = \"CHIRPS\")) + \n  theme_minimal() + \n  labs(title = \"Comparative Rainfall in Fort Collins\",\n       subtitle = \"1991-10-29 / 1991-11-03\",\n       color = \"Model\",\n       y = \"Rainfall (mm)\",\n       x = \"Date\")\n```\n\n### Integration with `zonal`\n\nWhile 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.\n\n```{r}\nlibrary(zonal)\n\nsystem.time({\n  chirps = getCHIRPS(AOI = colorado,\n               varname = \"precip\",\n               startDate = \"1991-10-29\",\n               endDate  = \"1991-11-06\") %\u003e% \n           execute_zonal(geom = colorado, \n                         fun = \"max\", \n                         ID = \"fip_code\")\n})\n```\n\n```{r, echo = FALSE}\nplot(chirps[grepl(\"precip_\", names(chirps))])\n```\n\n## Basic Animation\n\n### Gridded\n\n```{r, eval = FALSE}\nanimation(gridmet_pr$precipitation_amount, AOI = AOI, outfile = \"man/figures/rast_gif.gif\")\n```\n\n```{r, echo = FALSE}\nknitr::include_graphics(\"man/figures/rast_gif.gif\")\n```\n\n### Polygon\n\n```{r, eval = FALSE}\nanimation(max, feild_pattern = \"precip_\", outfile = \"man/figures/vect_gif.gif\")\n```\n\n```{r, echo = FALSE}\nknitr::include_graphics(\"man/figures/vect_gif.gif\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikejohnson51%2FclimateR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikejohnson51%2FclimateR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikejohnson51%2FclimateR/lists"}