mikejohnson51 / climateR

An R 📦 for getting point and gridded climate data by AOI
https://mikejohnson51.github.io/climateR/
MIT License
165 stars 40 forks source link

Add Average Option to PRISM Air Temperature #78

Closed katieelliott98 closed 11 months ago

katieelliott98 commented 11 months ago

Hi,

Thank you for creating this amazing package! I was hoping that tmean could be added as a param option for getPRISM(). I was able to create a workaround pretty easily but for making reproducible code that others could use, it would be helpful to have tmean already included.

Thanks!

mikejohnson51 commented 11 months ago

Hi @katieelliott98, thanks for the kind words! If you have the most up to date package, tmean should be an available varname for getPRISM(...).

Daily Data

library(AOI); library(climateR);library(terra)

tm = getPRISM(AOI = aoi_get(state = "CO", county = "Larimer"),
              startDate = "2018-01-01", endDate = "2018-01-04",
              varname = "tmean")

plot(tm[[1]])

Created on 2023-08-10 by the reprex package (v2.0.1)

Monthly data

However! it is not an available resource for the monthly aggregates. This is a due to the data on the respective servers. Since our main goal is to provide access to primary datasets, I am hesitant to add a mean function internally but will think about it because it does make sense in this case.

Until then you could try:

library(AOI); library(climateR);library(terra)

tm = getPRISM(AOI = aoi_get(state = "CO", county = "Larimer"),
              startDate = "2018-01-01", endDate = "2018-06-30",
              timeRes = "monthly",
              varname = c("tmn", "tmx"))

mm = mean(tm[[1]], tm[[2]])

plot(mm)

Created on 2023-08-10 by the reprex package (v2.0.1)

mikejohnson51 commented 11 months ago

Hi @katieelliott98, I hope this was a workable solution. I am closing for now but please reopen if it wasn't!