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

getTerraClim: Requested AOI not in model domain #38

Closed trefsland closed 3 years ago

trefsland commented 3 years ago

When trying to use getTerraClim, I'm running into the error 'Requested AOI not in model domain'. It happens whether I use bounding box or point data. Is this an issue with the server?

example <- aoi_get(country = "Argentina") %>% getTerraClim(param = c('tmax', 'tmin', 'prcp'), startDate = "2014-01-01")

Returns: "Error in withCallingHandlers(expr, warning = function(w) if (inherits(w, : Requested AOI not in model domain

mikejohnson51 commented 3 years ago

Hi, If you haven't in a while please try updating the package. Your example works well for me.

library(raster)
#> Loading required package: sp
library(climateR)

example <- AOI::aoi_get(country = "Argentina") %>%
  getTerraClim(param = c('tmax', 'tmin', 'prcp'), 
               startDate = "2014-01-01")

plot(stack(example))

Created on 2021-06-16 by the reprex package (v2.0.0)

If you have problems after updating please let me know!

Mike

trefsland commented 3 years ago

I reinstalled the packages, but the error persists. I also tried on another laptop with a clean R install, trying both the latest R version (4.1.0) and 3.6.3.

"Error in withCallingHandler(expr, warning = function(w) invokeRestart("muffleWarning")) Requested AOI not in model domain"

sessionInfo() shows climateR 0.1.0 and AOI 0.2.09000. I'm stumped.

urskalbitzer commented 3 years ago

Hi, First of all, a great and very useful package.

I have the same problems as @trefsland and get the same error message, even with the example above or the example from the README.md:

>kenya = aoi_get(country = "Kenya")
>tc = getTerraClim(kenya, param = "prcp", startDate = "2018-01-01")

Error in withCallingHandlers(expr, warning = function(w) if (inherits(w,  : 
  Requested AOI not in model domain

I have just installed the newest versions of climateR and AOI, but still have the same problems. And I believe that it worked yesterday, but I may have updated some other packages since then.

All help would be highly appreciated!

According to sessionInfo() other attached packages: [1] AOI_0.2.0.9000 climateR_0.1.0 raster_3.4-13 sp_1.4-5

urskalbitzer commented 3 years ago

I just tried it on my other computer, where the code above works just fine.

Here's the full information from sessionInfo() on the machine where it is working:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS  10.16

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] raster_3.4-10  sp_1.4-5       climateR_0.1.0

loaded via a namespace (and not attached):
 [1] tinytex_0.26        tidyselect_1.1.0    xfun_0.20           purrr_0.3.4         sf_0.9-8           
 [6] lattice_0.20-41     rnaturalearth_0.1.0 vctrs_0.3.6         generics_0.1.0      USAboundaries_0.3.1
[11] htmltools_0.5.1     yaml_2.2.1          blob_1.2.1          rlang_0.4.10        e1071_1.7-6        
[16] pillar_1.4.7        glue_1.4.2          DBI_1.1.1           RNetCDF_2.4-2       foreach_1.5.1      
[21] lifecycle_0.2.0     rgeos_0.5-5         rvest_0.3.6         AOI_0.1.9000        htmlwidgets_1.5.3  
[26] codetools_0.2-16    evaluate_0.14       knitr_1.30          doParallel_1.0.16   crosstalk_1.1.1    
[31] parallel_4.0.2      class_7.3-17        Rcpp_1.0.6          KernSmooth_2.23-17  classInt_0.4-3     
[36] jsonlite_1.7.2      leaflet_2.0.4.1     digest_0.6.27       dplyr_1.0.3         grid_4.0.2         
[41] rprojroot_2.0.2     rgdal_1.5-23        here_0.1            tools_4.0.2         magrittr_2.0.1     
[46] proxy_0.4-25        tibble_3.0.5        crayon_1.3.4        pkgconfig_2.0.3     ellipsis_0.3.1     
[51] xml2_1.3.2          assertthat_0.2.1    rmarkdown_2.4       httr_1.4.2          rstudioapi_0.13    
[56] iterators_1.0.13    R6_2.5.0            units_0.7-1         compiler_4.0.2     

If that is helpful, I can post the same information from the computer where I get the error message.

Thanks again, Urs

urskalbitzer commented 3 years ago

It seems that this is issue is related to the update of the sf-package from sf_0.9-8 to sf_1.0-1, and specifically with the use of s2. The code above works if s2 is deactivated:

library(sf)
sf_use_s2(FALSE)
library(raster)
#> Loading required package: sp
library(climateR)

example <- AOI::aoi_get(country = "Argentina") %>%
  getTerraClim(param = c('tmax', 'tmin', 'prcp'), 
               startDate = "2014-01-01")

plot(stack(example))

see: https://github.com/r-spatial/sf/issues/1649

trefsland commented 3 years ago

Excellent troubleshooting! I'm using sf_1.0-0 and deactivating s2 resolved the issue for me. Thanks so much for following up with what worked for you. Hopefully, this helps others as well.

mikejohnson51 commented 3 years ago

Hi all, thanks - I have been away from this package for a bit. I hope to get this fixed this weekend now that you have identified the problem @urskalbitzer. I appreciate it!

urskalbitzer commented 3 years ago

Glad it worked out and thanks again for this awesome package!

mikejohnson51 commented 3 years ago

Updates should be working now, a full fix is going to take some work with AOI, but thats for another day :)

library(climateR)
library(AOI)

example <- aoi_get(country = "Argentina") %>%
  getTerraClim(param = 'tmax', 
               startDate = "2014-01-01")
#> Spherical geometry (s2) switched off
#> Spherical geometry (s2) switched on

raster::plot(example[[1]])

Created on 2021-07-04 by the reprex package (v2.0.0)

DorotheaDeus commented 3 years ago

Excellent troubleshooting! I'm using sf_1.0-0 and deactivating s2 resolved the issue for me. Thanks so much for following up with what worked for you. Hopefully, this helps others as well.

Sure, deactivating s2 worked for me too, thank you so much

mikejohnson51 commented 3 years ago

Thanks again @urskalbitzer