USEPA / elevatr

An R package for accessing elevation data
Other
203 stars 26 forks source link

error with get_elev_point #73

Closed mhweber closed 2 years ago

mhweber commented 2 years ago

@jhollist , I'm guessing this may be related to changes with PROJ but running elevatr vignette code, as well as my own data, with get_elev_point is consistently returning error. Using:

   library(sp)
   library(elevatr)
   set.seed(65.7)
   examp_df <- data.frame(x = runif(3, min = -73, max = -72.5), 
                   y = runif(3, min = 42 , max = 43))
   prj_dd <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
   # Create and example data.frame with additional columns
   cats <- data.frame(category = c("H", "M", "L"))
   examp_df2 <- data.frame(examp_df, cats)
   # Create an example SpatialPoints
   examp_sp <- SpatialPoints(examp_df, proj4string = CRS(prj_dd))
   # Create an example SpatialPointsDataFrame
    examp_spdf <- SpatialPointsDataFrame(examp_sp, data = cats)

And then running:

   df_elev_epqs <- get_elev_point(examp_df, prj = prj_dd, src = "epqs")

I get:

   Error in h(simpleError(msg, call)) :  error in evaluating the argument 'CRSobj' in selecting a method for function 'spTransform': NA

Same error with all of these:

 df2_elev_epqs <- get_elev_point(examp_df2, prj = prj_dd, src = "epqs")
 sp_elev_epqs <- get_elev_point(examp_sp, src = "epqs")
 spdf_elev_epqs <- get_elev_point(examp_spdf, src = "epqs")

And with this simple example:

test <- data.frame(x=-71.4474, y=44.0945) %>% 
     st_as_sf(coords=c('x','y'),crs=4326)
elev <- get_elev_raster(test, z=10)
# or elev <- get_elev_point(test, src="aws")

Maybe something really simple I'm completely missing? Here's my sessionInfo():

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8 
[2] LC_CTYPE=English_United States.utf8   
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

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

other attached packages:
[1] sp_1.5-0           reticulate_1.24    nhdplusTools_0.5.2 elevatr_0.4.3.9999
[5] readxl_1.4.0       stringr_1.4.0      readr_2.1.2        dplyr_1.0.7       
[9] sf_1.0-7          

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.7         lattice_0.20-45    tidyr_1.2.0       
 [4] png_0.1-7          prettyunits_1.1.1  class_7.3-20      
 [7] ps_1.6.0           assertthat_0.2.1   rprojroot_2.0.2   
[10] digest_0.6.27      utf8_1.1.4         R6_2.5.1          
[13] cellranger_1.1.0   evaluate_0.15      e1071_1.7-4       
[16] httr_1.4.3         pillar_1.7.0       rlang_1.0.2       
[19] curl_4.3.2         rstudioapi_0.13    callr_3.7.0       
[22] Matrix_1.4-1       rmarkdown_2.14     rgdal_1.5-23      
[25] compiler_4.2.1     xfun_0.25          pkgconfig_2.0.3   
[28] pkgbuild_1.2.0     htmltools_0.5.2    tidyselect_1.1.2  
[31] tibble_3.1.3       RANN_2.6.1         progressr_0.10.1  
[34] fansi_0.4.2        crayon_1.5.1       tzdb_0.1.2        
[37] withr_2.5.0        later_1.1.0.1      grid_4.2.1        
[40] jsonlite_1.8.0     lifecycle_1.0.1    DBI_1.1.3         
[43] magrittr_2.0.1     units_0.7-0        zip_2.1.1         
[46] KernSmooth_2.23-20 cli_3.0.1          stringi_1.7.3     
[49] pbapply_1.4-3      remotes_2.4.0      xml2_1.3.2        
[52] ellipsis_0.3.2     generics_0.1.2     vctrs_0.3.8       
[55] fst_0.9.4          tools_4.2.1        glue_1.4.2        
[58] purrr_0.3.4        hms_1.1.1          processx_3.5.2    
[61] parallel_4.2.1     fastmap_1.1.0      yaml_2.2.1        
[64] classInt_0.4-3     knitr_1.33         quarto_1.2
mhweber commented 2 years ago

It must be something idiosyncratic with the library configuration I have above - the following code on a different machine with the sessionInfo() shown below works fine - so perhaps can close and consider issue just an edge case with library configuration I have shown above?

   test <- data.frame(x=-71.4474, y=44.0945) %>% 
        st_as_sf(coords=c('x','y'),crs=4326)

    elev <- get_elev_point(test, src="epqs")

   sessionInfo()

   R version 4.2.1 (2022-06-23 ucrt)
   Platform: x86_64-w64-mingw32/x64 (64-bit)
   Running under: Windows 10 x64 (build 19042)

   Matrix products: default

   locale:
   [1] LC_COLLATE=English_United States.utf8 
   [2] LC_CTYPE=English_United States.utf8   
   [3] LC_MONETARY=English_United States.utf8
   [4] LC_NUMERIC=C                          
   [5] LC_TIME=English_United States.utf8    

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

  other attached packages:
  [1] elevatr_0.4.2 sf_1.0-8      dplyr_1.0.8  

  loaded via a namespace (and not attached):
  [1] Rcpp_1.0.8.3       pillar_1.7.0      
  [3] compiler_4.2.1     progressr_0.9.0   
  [5] prettyunits_1.1.1  class_7.3-20      
  [7] tools_4.2.1        progress_1.2.2    
  [9] digest_0.6.29      jsonlite_1.8.0    
 [11] lifecycle_1.0.1    tibble_3.1.8      
 [13] lattice_0.20-45    pkgconfig_2.0.3   
 [15] rlang_1.0.2        DBI_1.1.2         
 [17] cli_3.2.0          curl_4.3          
 [19] rgdal_1.5-32       e1071_1.7-9       
 [21] raster_3.4-13      httr_1.4.3        
 [23] generics_0.1.2     vctrs_0.4.1       
 [25] hms_1.1.1          classInt_0.4-3    
 [27] grid_4.2.1         tidyselect_1.1.2  
 [29] glue_1.6.2         R6_2.5.1          
 [31] fansi_1.0.3        sp_1.5-0          
 [33] purrr_0.3.4        magrittr_2.0.3    
 [35] codetools_0.2-18   ellipsis_0.3.2    
 [37] units_0.8-0        assertthat_0.2.1  
 [39] utf8_1.2.2         KernSmooth_2.23-20
 [41] slippymath_0.3.1   proxy_0.4-26      
 [43] crayon_1.5.1 
mhweber commented 2 years ago

solved - fixed by updating rcpp from Rcpp_1.0.7 to Rcpp_1.0.9 and rgdal from rgdal_1.5-23 to rgdal_1.5-32 - not clear if it was rgdal or rcpp update that was needed.

jhollist commented 2 years ago

Thanks for reporting the fix! I need to get elevatr switch fully to sf. On my list for the fall.

On Wed, Aug 17, 2022, 5:42 PM Marc Weber @.***> wrote:

solved - fixed by updating rcpp from Rcpp_1.0.7 to Rcpp_1.0.9 and rgdal from rgdal_1.5-23 to rgdal_1.5-32 - not clear if it was rgdal or rcpp update that was needed.

— Reply to this email directly, view it on GitHub https://github.com/jhollist/elevatr/issues/73#issuecomment-1218517180, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPYSYOXOWENYC7OO5FNOTVZVMFLANCNFSM56XWTNSA . You are receiving this because you were mentioned.Message ID: @.***>