mikejohnson51 / climateR

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

getPRISM and getDaymet errors #41

Closed joeyblumberg closed 1 year ago

joeyblumberg commented 3 years ago

PRISM:

prism_prcp_1mo <- getPRISM(AOI = aoi_get(state = "AZ"), param = "prcp", startDate = "1990-01-01", endDate = "1990-02-01")

'Error in dim(v) <- round(c(g$rows, g$cols, time)) : dims [product 613760] do not match the length of object [19180]'

getPRISM() was working fine for me until I recently updated R and all packages. It still works when pulling data for single days.

Daymet:

daymet_prcp_1day <- getDaymet(AOI = aoi_get(state = "AZ"), param = "prcp", startDate = "1990-01-01")

'Error in var[[i]] * scale_factor : non-numeric argument to binary operator'

atsyplenkov commented 2 years ago

Any update on this? I have the same error while running getTerraClim on my Windows machine.

library(AOI)
library(climateR)
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(raster)
library(rasterVis)

kenya = aoi_get(country = "Kenya")
tc = getTerraClim(kenya, param = "prcp", startDate = "2018-01-01")
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on
#> Error in var[[i]] * scale_factor : 
  non-numeric argument to binary operator

sessionInfo()

R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=Russian_Russia.1251  LC_CTYPE=Russian_Russia.1251   
[3] LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C                   
[5] LC_TIME=Russian_Russia.1251    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reprex_2.0.1     rasterVis_0.51.2 lattice_0.20-45  raster_3.5-15   
[5] sp_1.4-6         sf_1.0-5         climateR_0.1.0   AOI_0.2.0.9000  
mikejohnson51 commented 1 year ago

Hi @joeyblumberg and @atsyplenkov,

Thank you for this issue and sorry for the long delay on this. The package has been completely re-written to supply greater flexibility, more datasets, and easier use. In this example, the issues in PRISM and Daymet have been resolved:

library(AOI)
library(climateR)
#> Using GDAL version 3.6.0 which was retracted because it cannot write large GPKG files
library(terra)
#> terra 1.7.8

# Used tmin instead of ppt to see values, both work though
prism_tmin_1mo <- getPRISM(AOI = aoi_get(state = "AZ"),
                           varname = "tmin",
                           startDate = "1990-01-01",
                           endDate = "1990-02-01")

plot(prism_tmin_1mo$tmin$`tmin_1990-01-01`)


daymet_prcp_1day <- getDaymet(AOI = aoi_get(state = "AZ"),
                              varname = "prcp",
                              startDate = "1990-01-01")

plot(daymet_prcp_1day$prcp_total)


kenya = aoi_get(country = "Kenya")
tc = getTerraClim(kenya, varname = "ppt", startDate = "2018-01-01")

plot(tc$ppt_total)

Created on 2023-02-15 by the reprex package (v2.0.1)

I hope the package rewrite proves useful to you if you are still using it and pursuing simular research/data questions.

Mike