PRISM
Download data from the Oregon PRISM climate data project.
https://github.com/ropensci/prism
Category: Climate Change
Sub Category: Climate Data Access and Visualization
Keywords
r r-package rstats
Keywords from Contributors
climate ecology tidyverse routes cycle species-distribution-modeling weather noaa birds reproducibility
Last synced: about 12 hours ago
JSON representation
Repository metadata
Download data from the Oregon PRISM climate data project http://www.prism.oregonstate.edu/
- Host: GitHub
- URL: https://github.com/ropensci/prism
- Owner: ropensci
- License: other
- Created: 2014-03-25T04:49:41.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2025-03-26T15:01:14.000Z (about 1 month ago)
- Last Synced: 2025-04-25T14:07:34.293Z (1 day ago)
- Topics: r, r-package, rstats
- Language: R
- Homepage: https://docs.ropensci.org/prism
- Size: 77.8 MB
- Stars: 58
- Watchers: 7
- Forks: 25
- Open Issues: 16
- Releases: 5
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Codemeta: codemeta.json
README.Rmd
--- output: github_document --- ```{r, echo = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" ) # knitr hook to truncate long output. See: # https://stackoverflow.com/q/23114654/3362993 hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set(output = function(x, options) { if (!is.null(n <- options$out.lines)) { x <- unlist(strsplit(x, "\n")) if (length(x) > n) { # truncate the output x <- c(head(x, n), "....\n") } x <- paste(x, collapse = "\n") } hook_output(x, options) }) ``` # `prism` [](https://cran.r-project.org/package=prism) [](https://github.com/ropensci/prism/actions) [](https://app.codecov.io/github/ropensci/prism?branch=master) This package allows users to access and visualize data from the [Oregon State PRISM project](https://prism.nacse.org). Data are all in the form of gridded rasters for the continental US at 4 different temporal scales: daily, monthly, annual, and 30 year normals. Please see their webpage for a full description of the data products, or [see their overview](https://www.prism.oregonstate.edu/documents/PRISM_datasets.pdf). ## Installation prism is available on CRAN: ```{r eval=FALSE} install.packages("prism") ``` Or the development version can be installed from GitHub with devtools: ```{r start, eval=FALSE} # install.packages("devtools") library(devtools) install_github("ropensci/prism") ``` ## Quickstart The overall work flow in the prism package is (links go to details on this page): 1. [Set the download directory](#downloading-data), i.e., the folder on your computer that prism data will be saved to: `prism_set_dl_dir()`. This is now referred to as the "prism archive". 2. [Download prism data to the archive:](#download-30-year-normal-data) `get_prism_*()`. Each folder, or variable, timestep, day/month/year is stored in a single folder in the archive and referred to as prism data (`pd`). 3. [Interact with the prism archive:](#interact-with-the-archive-and-prism-data) `prism_archive_*()`. Or interact with the prism data: `pd_*()`. The remainder of this README provides examples following this work flow. ## prism data and parameters Data are available in 4 different temporal scales as mentioned above. At each temporal scale, there are 11 different parameters/variables available. Keep in mind these are modeled parameters, not measured. Please see the [full description](https://www.prism.oregonstate.edu/documents/PRISM_datasets.pdf) for how they are calculated. | Parameter name| Description | |:---------------|:-------------| | *tmean* | Mean temperature | | *tmax* | Maximum temperature | | *tmin* | Minimum temperature | | *tdmean* | Mean dew point temperature | | *ppt* | Total precipitation (rain and snow)| | *vpdmin* | Daily minimum vapor pressure deficit | | *vpdmax* |Daily maximum vapor pressure deficit | | *solclear* | Solar radiation (clear sky) | | *solslope* | Solar radiation (sloped) | | *soltotal* | Solar radiation (total) | | *soltrans* | Cloud transmittance | ### Data availability **Normals (4km or 800m resolution) based on 1991-2020 average:** | Variable | Annual | Monthly | Daily | |:------------|:-------|:--------|:-----| | *tmean* | X | X | X | | *tmax* | X | X | X | | *tmin* | X | X | X | | *tdmean* | X | X | X | | *ppt* | X | X | X | | *vpdmin* | X | X | X | | *vpdmax* | X | X | X | | *solclear* | X | X | | | *solslope* | X | X | | | *soltotal* | X | X | | | *soltrans* | X | X | | **Daily, monthly, and annual data:** | Variable | Annual (1895-present) | Monthly (1895-present) | Daily (1981-present) | |:------------|:-------|:--------|:-----| | *tmean* | X | X | X | | *tmax* | X | X | X | | *tmin* | X | X | X | | *tdmean* | X | X | X | | *ppt* | X | X | X | | *vpdmin* | X | X | X | | *vpdmax* | X | X | X | | *solclear* | | | | | *solslope* | | | | | *soltotal* | | | | | *soltrans* | | | | ## Downloading data Before downloading any data, set the directory that the prism data will be saved to: ```{r prism setup} library(prism) prism_set_dl_dir("~/prismtmp") ``` This is now referred to as the "prism archive". The `prism_archive_*()` functions allow the user to search through the archive. The prism archive contains "prism data". The prism data are referred to by their folder names, even though the "real" data are the .bil, .txt, and other files that exist in the folder. The prism data (`pd`) can be accessed using the `pd_*()` functions. ### Download 30-year normal data Normals are based on the latest 30-year period; currently 1981 - 2010. Normals can be downloaded in two resolutions, 4km and 800m, and a resolution must be specified. They can be downloaded for a given day, month, vector of days/months, or annual averages for all 30 years. ```{r get normals,results=FALSE, eval=FALSE} # Download March 14 30-year average precip. Note the year is ignored get_prism_normals('ppt', '4km', day = as.Date('2025-03-14')) # Download the January - June 30-year averages at 4km resolution get_prism_normals(type="tmean", resolution = "4km", mon = 1:6, keepZip = FALSE) # Download the 30-year annual average precip and annual average temperature get_prism_normals("ppt", "4km", annual = TRUE, keepZip = FALSE) get_prism_normals("tmean", "4km", annual = TRUE, keepZip = FALSE) ``` If the archive has not already been set, calling any of the `get_prism_*()` functions will prompt the user to specify the directory. prism data are downloaded as zip files and then unzipped. If the `keepZip` argument is `TRUE` the zip file will remain on your machine, otherwise it will be automatically deleted. ### Download daily, monthly, and annual data Let us download daily average temperatures from June 1 to June 14, 2013. We can also download January average temperature data from 1982 to 2014. Finally, we will download annual average precipitation for 2000 to 2015. ```{r get daily monthly, message=FALSE, results=FALSE, eval=FALSE} get_prism_dailys( type = "tmean", minDate = "2013-06-01", maxDate = "2013-06-14", keepZip = FALSE ) get_prism_monthlys(type = "tmean", year = 1982:2014, mon = 1, keepZip = FALSE) get_prism_annual("ppt", years = 2000:2015, keepZip = FALSE) ``` Note that for daily data you need to give a well formed date string in the form of "YYYY-MM-DD". ## Interact with the archive and prism data You can view all the prism data you have downloaded with a simple command: `prism_archive_ls()`. This function gives a list of folder names, i.e., prism data (`pd`). All the functions in the prism package work off of one or more of these folder names (`pd`). ```{r listingFiles, out.lines=10} ## Truncated to keep file list short prism_archive_ls() ``` While prism functions use this folder format, other files may need an absolute path (e.g. the `raster` package). The `pd_to_file()` function conveniently returns the absolute path. Alternatively, you may want to see what the normal name for the product is (not the file name), and we can get that with the `pd_get_name()` function. ```{r moreListing, out.lines=5} ## Truncated to keep file list short pd_to_file(prism_archive_ls()) pd_get_name(prism_archive_ls()) ``` Finally, `prism_archive_subset()` is a convenient way to search for specific parameters, time steps, days, months, years, or ranges of days, months, years. ```{r} # we know we have downloaded June 2013 daily data, so lets search for those prism_archive_subset("tmean", "daily", mon = 6) # or we can look for days between June 7 and June 10 prism_archive_subset( "tmean", "daily", minDate = "2013-06-07", maxDate = "2013-06-10" ) ``` ### Raster plots You can easily make a quick plot of your data using the output of `prism_archive_ls()` or `prism_archive_subset()` with `pd_image()`. ```{r quick_plot,fig.height=5,fig.width=7} # Plot the January 30-year average temperatures jmean <- prism_archive_subset( "tmean", "monthly normals", mon = 1, resolution = "4km" ) pd_image(jmean) ``` It is easy to load the prism data with the raster package. This time we will look at January temperature anomalies. To do this we will examine the difference between January 2013 and the January 30-year normals. Conveniently, we already downloaded these data. We just need to grab them out of our archive. ```{r raster_math,fig.height=5,fig.width=7} library(raster) # knowing the name of the files you are after allows you to find them in the # list of all files that exist # jnorm_name <- "PRISM_tmean_30yr_normal_4kmM2_01_bil" # j2013_name <- "PRISM_tmean_stable_4kmM3_201301_bil" # but we will use prism_archive_subset() to find the files we need jnorm <- prism_archive_subset( "tmean", "monthly normals", mon = 1, resolution = "4km" ) j2013 <- prism_archive_subset("tmean", "monthly", years = 2013, mon = 1) # raster needs a full path, not the "short" prism data name jnorm <- pd_to_file(jnorm) j2013 <- pd_to_file(j2013) ## Now we'll load the rasters. jnorm_rast <- raster(jnorm) j2013_rast <- raster(j2013) # Now we can do simple subtraction to get the anomaly by subtracting 2014 # from the 30 year normal map anomCalc <- function(x, y) { return(x - y) } anom_rast <- raster::overlay(j2013_rast,jnorm_rast,fun = anomCalc) plot(anom_rast) ``` The plot shows that January 2013 was warmer than the average over the last 30 years. It also shows how easy it is to use the raster library to work with prism data. The package provides a simple framework to work with a large number of rasters that you can easily download and visualize or use with other data sets. ### Single grid cell plot You can also visualize a single point across multiple prism data files (slice) using `pd_plot_slice()`. This procedure will take a set of rasters, create a "`raster::stack`", extract data at a point, and then create a ggplot2 object. Let's now make a plot of January temperatures in Boulder between 1982 and 2014. First we'll grab all the data from the US (downloaded in the previous step), and then give our function a point to get data from. The point must be a vector in the form of longitude, latitude. Because `pd_plot_slice()` returns a gg object, it can be combined with other ggplot functions. ```{r plot_Boulder,fig.height=5,fig.width=7, results=FALSE} library(ggplot2) # data already exist in the prism dl dir boulder <- c(-105.2797, 40.0176) # prism_archive_subset() will return prism data that matches the specified # variable, time step, years, months, days, etc. to_slice <- prism_archive_subset("tmean", "monthly", mon = 1) p <- pd_plot_slice(to_slice, boulder) # add a linear average and title p + stat_smooth(method="lm", se = FALSE) + theme_bw() + ggtitle("Average January temperature in Boulder, CO 1982-2014") ``` ### leaflet map Finally, the prism data are in a form that can be used with leaflet maps (with the help of the raster package). The [leaflet package](https://CRAN.R-project.org/package=leaflet) allows you to easily make JavaScript maps using the [leaflet](https://leafletjs.com/) mapping framework using prism data. These can easily be hosted on websites like [Rpubs](https://rpubs.com/) or your own site. Here is a simple example of plotting the [30-year normal for annual temperature](https://rpubs.com/DistribEcology/122453). If you run this code you will have an interactive map, instead of just the screen shot shown here. ```{r leaflet,eval=F} library(leaflet) library(raster) library(prism) # 30-year normal average temperature have already been downloaded for norm <- prism_archive_subset( "tmean", "annual normals", resolution = "4km" ) rast <- raster(pd_to_file(norm)) # Create color palette and plot pal <- colorNumeric( c("#0000FF", "#FFFF00", "#FF0000"), values(rast), na.color = "transparent" ) leaflet() %>% addTiles( urlTemplate = 'http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}' ) %>% addRasterImage(rast, colors = pal, opacity=.65) %>% addLegend(pal = pal, values = values(rast), title = "Deg C") ``` [
Owner metadata
- Name: rOpenSci
- Login: ropensci
- Email: [email protected]
- Kind: organization
- Description:
- Website: https://ropensci.org/
- Location: Berkeley, CA
- Twitter: rOpenSci
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1200269?v=4
- Repositories: 307
- Last ynced at: 2023-03-10T20:30:59.242Z
- Profile URL: https://github.com/ropensci
GitHub Events
Total
- Create event: 2
- Release event: 2
- Issues event: 11
- Watch event: 4
- Issue comment event: 11
- Push event: 17
- Pull request event: 2
Last Year
- Create event: 2
- Release event: 2
- Issues event: 11
- Watch event: 4
- Issue comment event: 11
- Push event: 17
- Pull request event: 2
Committers metadata
Last synced: 7 days ago
Total Commits: 393
Total Committers: 17
Avg Commits per committer: 23.118
Development Distribution Score (DDS): 0.344
Commits in past year: 30
Committers in past year: 3
Avg Commits per committer in past year: 10.0
Development Distribution Score (DDS) in past year: 0.1
Name | Commits | |
---|---|---|
Alan Butler | r****r@u****v | 258 |
Ted Hart | e****t@g****m | 67 |
Kendon | k****6@b****u | 31 |
Jordan home | j****d@u****v | 11 |
Kendon Bell | k****B | 5 |
jsta | s****2@m****u | 4 |
Scott Chamberlain | m****s@g****m | 4 |
steven2249 | s****w@b****u | 3 |
Andrew Gene Brown | a****n@u****v | 2 |
Andrew Gillreath-Brown | A****r | 1 |
Ethan White | e****n@w****g | 1 |
rOpenSci Bot | m****t@g****m | 1 |
Alan Butler | r****7@g****u | 1 |
Adam Smith | a****h@m****g | 1 |
Adam B. Smith | a****m@e****g | 1 |
Shawn | s****r | 1 |
mark padgham | m****m@e****m | 1 |
Committer domains:
- berkeley.edu: 2
- email.com: 1
- earthskysea.org: 1
- mobot.org: 1
- gatech.edu: 1
- weecology.org: 1
- usda.gov: 1
- msu.edu: 1
- usgs.gov: 1
- usbr.gov: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 104
Total pull requests: 31
Average time to close issues: 4 months
Average time to close pull requests: about 2 months
Total issue authors: 26
Total pull request authors: 14
Average comments per issue: 1.76
Average comments per pull request: 0.42
Merged pull request: 27
Bot issues: 0
Bot pull requests: 0
Past year issues: 6
Past year pull requests: 2
Past year average time to close issues: 1 day
Past year average time to close pull requests: 5 months
Past year issue authors: 3
Past year pull request authors: 2
Past year average comments per issue: 0.33
Past year average comments per pull request: 0.5
Past year merged pull request: 2
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- emhart (31)
- rabutler-usbr (30)
- kendonB (9)
- rabutler (5)
- sckott (5)
- Aariq (3)
- ctloftin (2)
- arbgoetz (1)
- jbreng (1)
- sheilasaia (1)
- kruehling (1)
- bglarkin (1)
- aramcharan (1)
- haoranliu666 (1)
- ylarissa (1)
Top Pull Request Authors
- kendonB (7)
- rabutler (5)
- jsta (4)
- rabutler-usbr (3)
- emhart (3)
- ethanwhite (1)
- sdtaylor (1)
- Aariq (1)
- stevenysw (1)
- jordansread (1)
- adamlilith (1)
- brownag (1)
- Archaeo-Programmer (1)
- mpadge (1)
Top Issue Labels
- bug (14)
- enhancement (11)
- question (1)
- wontfix (1)
Top Pull Request Labels
Package metadata
- Total packages: 1
-
Total downloads:
- cran: 830 last-month
- Total docker downloads: 88,618
- Total dependent packages: 0
- Total dependent repositories: 2
- Total versions: 6
- Total maintainers: 1
cran.r-project.org: prism
Access Data from the Oregon State Prism Climate Project
- Homepage: https://docs.ropensci.org/prism/
- Documentation: http://cran.r-project.org/web/packages/prism/prism.pdf
- Licenses: MIT + file LICENSE
- Latest release: 0.2.3 (published about 1 month ago)
- Last Synced: 2025-04-25T14:03:17.759Z (1 day ago)
- Versions: 6
- Dependent Packages: 0
- Dependent Repositories: 2
- Downloads: 830 Last month
- Docker Downloads: 88,618
-
Rankings:
- Forks count: 3.648%
- Stargazers count: 6.292%
- Average: 16.863%
- Dependent repos count: 19.609%
- Downloads: 26.782%
- Dependent packages count: 27.984%
- Maintainers (1)
Dependencies
- dplyr * imports
- ggplot2 * imports
- httr * imports
- magrittr * imports
- purrr * imports
- raster * imports
- readr * imports
- stringr * imports
- utils * imports
- covr * suggests
- knitr * suggests
- rmarkdown * suggests
- testthat >= 2.1.0 suggests
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
Score: 18.538735884806997