Skip to contents

Download grid cell data from the prism project. Temperature (min, max, and mean), mean dewpoint temperature, precipitation, and vapor pressure deficit (min and max) can be downloaded for annual (get_prism_annual()), monthly (get_prism_monthlys()), daily (get_prism_dailys()), and 30-year averages (get_prism_normals()). Data are at 4km resolution, except for the normals which can also be downloaded at 800m resolution.

Download data from the prism project for 30 year normals at 4km or 800m grid cell resolution for precipitation, mean, min and max temperature

Usage

get_prism_annual(
  type,
  years,
  keepZip = TRUE,
  keep_pre81_months = FALSE,
  service = NULL
)

get_prism_dailys(
  type,
  minDate = NULL,
  maxDate = NULL,
  dates = NULL,
  keepZip = TRUE,
  check = "httr",
  service = NULL
)

get_prism_monthlys(
  type,
  years,
  mon = 1:12,
  keepZip = TRUE,
  keep_pre81_months = TRUE,
  service = NULL
)

get_prism_normals(type, resolution, mon = NULL, annual = FALSE, keepZip = TRUE)

Arguments

type

The type of data to download. Must be "ppt", "tmean", "tmin", "tmax", "tdmean", "vpdmin", or "vpdmax". Note that tmean == mean(tmin, tmax).

years

a valid numeric year, or vector of years, to download data for.

keepZip

if TRUE, leave the downloaded zip files in your 'prism.path', if FALSE, they will be deleted.

keep_pre81_months

The pre-1981 data includes all monthly data and the annual data for the specified year. If you need annual and monthly data it is advantageous to keep all the monthly data when downloading the annual data so you don't have to download the zip file again. When downloading annual data, this defaults to FALSE. When downloading monthly data, this defaults to TRUE.

service

Either NULL (default) or a URL provided by PRISM staff for subscription-based service. Example: "http://services.nacse.org/prism/data/subscription/800m". To use the subscription option, you must use an IP address registered with PRISM staff. When NULL, URL defaults to: "http://services.nacse.org/prism/data/public/4km".

minDate

Date to start downloading daily data. Must be specified in a valid iso-8601 (e.g. YYYY-MM-DD) format. May be provided as either a character or base::Date class.

maxDate

Date to end downloading daily data. Must be specified in a valid iso-8601 (e.g. YYYY-MM-DD) format. May be provided as either a character or base::Date class.

dates

A vector of dates to download daily data. Must be specified in a valid iso-8601 (e.g. YYYY-MM-DD) format. May be provided as either a character or base::Date class.

check

One of "httr" or "internal". See details.

mon

a valid numeric month, or vector of months. Required for get_prism_monthlys(). Can be NULL for get_prism_normals().

resolution

The spatial resolution of the data, must be either "4km" or "800m".

annual

if TRUE download annual normals.

Value

Nothing is returned - an error will occcur if download is not successful.

Details

A valid download directory must exist before downloading any prism data. This can be set using prism_set_dl_dir() and can be verified using prism_check_dl_dir().

For the check parameter, "httr", the default, checks the file name using the web service, and downloads if that file name is not in the file system. "internal" (much faster) only attempts to download layers that are not already in the file system as stable. "internal" should be used with caution as it is not robust to changes in version or file names.

Annual and Monthly

Annual and monthly prism data are available from 1891 to present. For 1891-1980 data, monthly and annual data are grouped together in one download file; keep_pre81_months determines if the other months/yearly data are kept after the download. Data will be downloaded for all specified months (mon) in all the years in the supplied vectors.

Daily

Daily prism data are available beginning on January 1, 1981. To download the daily data, dates must be in the proper format or downloading will not work properly. Dates can be specified using either a date range via minDate and maxDate, or a vector of dates, but not both.

Normals

30-year normals are currently computed using 1991-2020 and are available at 4km and 800m resolution. See https://prism.nacse.org/normals/. If mon is specified and annual is TRUE, then monthly and annual normal data will be downloaded.

Examples

if (FALSE) {
# Get all annual average temperature data from 1990 to 2000
get_prism_annual(type = "tmean", year = 1990:2000, keepZip = FALSE)
}

if (FALSE) {
# get daily average temperature data for June 1 - 14, 2013
get_prism_dailys(
  type = "tmean", 
  minDate = "2013-06-01", 
  maxDate = "2013-06-14", 
  keepZip=FALSE
)

# get precipitation datat for June 1, 2013
get_prism_dailys(type = "ppt", dates = "2013/06/01", keepZip = FALSE)

# get average temperature for three specific days
get_prism_dailys(
  type="tmean", 
  dates = as.Date("2013-06-01", "2013-06-14", "2014-06-30"), 
  keepZip=FALSE
)

# will fail:
get_prism_dailys(
  type = "ppt", 
  minDate = "2013-06-01", 
  dates = "2013-06-14", 
  keepZip = FALSE
)

get_prism_dailys(
  type = "ppt", 
  minDate = "2013-06-01", 
  keepZip=FALSE
)
}

if (FALSE) {
# Get all the precipitation data for January from 1990 to 2000
get_prism_monthlys(type = "ppt", years = 1990:2000, mon = 1, keepZip = FALSE)

# Get January-December 2005 monthly precipitation
get_prism_monthlys(type = "ppt", years = 2005, mon = 1:12, keepZip = FALSE)
}

if (FALSE) {
# Get 30 year normal values for January rainfall
get_prism_normals(type = "ppt", resolution = "4km", mon = 1, keepZip = FALSE)

# Get monthly (every month) and annual 30-year normals for mean temperature
get_prism_normals(
  type = "tmean", 
  resolution = "800m", 
  mon = 1:12, 
  annual = TRUE,
  keepZip = FALSE
)
}