Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot re-produce results from vignette section "Transition* classes" #14

Closed
ZekeMarshall opened this issue Jan 10, 2023 · 4 comments
Closed

Comments

@ZekeMarshall
Copy link

ZekeMarshall commented Jan 10, 2023

Hi,

Thank you for your work on the {gdistance} package, it looks extremely useful!

Apologies if I am missing something, but i'm failing to reproduce the results from the vignette section "Transition* classes".

Specifically, I'm running the following code

library("gdistance")
set.seed(123)
r <- raster(ncol=3,nrow=3)
r[] <- 1:ncell(r)
r
r[] <- 1
r
tr1 <- transition(r, transitionFunction=mean, directions=8)

and have received the following error message.

Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'x' in selecting a method for function 'extent': ‘srs’ is not a slot in class “BasicRaster”

I've tried this with both the CRAN and github installations of {gdistance}.

Any help would be greatly appreciated!

Best regards,

Zeke


Session Information:

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

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

other attached packages:
 [1] gdistance_1.6       Matrix_1.5-1        igraph_1.3.5        raster_3.6-11       sp_1.5-1            nlme_3.1-160       
 [7] AICcmodavg_2.3-1    elevatr_0.4.2       rmarkdown_2.19      sfheaders_0.4.0     sf_1.0-9            rhandsontable_0.3.8
[13] sgo_0.9.2           bs4Dash_2.2.1       bsplus_0.1.4        rgbif_3.7.4         leafem_0.2.0        geojsonsf_2.0.3    
[19] leafpm_0.1.0        leaflet_2.1.1       shinyjs_2.1.0       forcats_0.5.2       stringr_1.5.0       dplyr_1.0.10       
[25] purrr_1.0.0         readr_2.1.3         tidyr_1.2.1         tibble_3.1.8        ggplot2_3.4.0       tidyverse_1.3.2    
[31] shiny_1.7.4        

loaded via a namespace (and not attached):
  [1] readxl_1.4.1            uuid_1.1-0              backports_1.4.1         VGAM_1.1-7              plyr_1.8.8             
  [6] lazyeval_0.2.2          splines_4.2.2           crosstalk_1.2.0         unmarked_1.2.5          usethis_2.1.6          
 [11] urltools_1.7.3          digest_0.6.31           htmltools_0.5.4         leaflet.providers_1.9.0 fansi_1.0.3            
 [16] magrittr_2.0.3          memoise_2.0.1           jsonify_1.2.2           googlesheets4_1.0.1     remotes_2.4.2          
 [21] tzdb_0.3.0              modelr_0.1.10           timechange_0.1.1        prettyunits_1.1.1       colorspace_2.0-3       
 [26] rvest_1.0.3             haven_2.5.1             xfun_0.36               callr_3.7.3             crayon_1.5.2           
 [31] jsonlite_1.8.4          progressr_0.12.0        survival_3.4-0          glue_1.6.2              gtable_0.3.1           
 [36] gargle_1.2.1            pkgbuild_1.4.0          scales_1.2.1            oai_0.4.0               DBI_1.1.3              
 [41] miniUI_0.1.1.1          Rcpp_1.0.9              xtable_1.8-4            units_0.8-1             proxy_0.4-27           
 [46] stats4_4.2.2            profvis_0.3.7           htmlwidgets_1.6.0       httr_1.4.4              RColorBrewer_1.1-3     
 [51] wk_0.7.1                ellipsis_0.3.2          urlchecker_1.0.1        pkgconfig_2.0.3         farver_2.1.1           
 [56] sass_0.4.4              dbplyr_2.2.1            utf8_1.2.2              conditionz_0.1.0        crul_1.3               
 [61] tidyselect_1.2.0        rlang_1.0.6             later_1.3.0             munsell_0.5.0           cellranger_1.1.0       
 [66] tools_4.2.2             cachem_1.0.6            cli_3.5.0               generics_0.1.3          devtools_2.4.5         
 [71] broom_1.0.2             evaluate_0.19           fastmap_1.1.0           yaml_2.3.6              processx_3.8.0         
 [76] knitr_1.41              fs_1.5.2                s2_1.1.1                pbapply_1.6-0           whisker_0.4.1          
 [81] mime_0.12               xml2_1.3.3              compiler_4.2.2          rstudioapi_0.14         curl_4.3.3             
 [86] png_0.1-8               e1071_1.7-12            reprex_2.0.2            bslib_0.4.2             stringi_1.7.8          
 [91] ps_1.7.2                desc_1.4.2              lattice_0.20-45         classInt_0.4-8          vctrs_0.5.1            
 [96] pillar_1.8.1            lifecycle_1.0.3         triebeard_0.3.0         jquerylib_0.1.4         data.table_1.14.6      
[101] httpuv_1.6.7            R6_2.5.1                promises_1.2.0.1        renv_0.16.0             KernSmooth_2.23-20     
[106] sessioninfo_1.2.2       codetools_0.2-18        pkgload_1.3.2           MASS_7.3-58.1           assertthat_0.2.1       
[111] fontawesome_0.4.0       rprojroot_2.0.3         withr_2.5.0             httpcode_0.3.0          parallel_4.2.2         
[116] hms_1.1.2               terra_1.6-47            grid_4.2.2              class_7.3-20            googledrive_2.0.0      
[121] lubridate_1.9.0         base64enc_0.1-3 
@ZekeMarshall
Copy link
Author

This now works after re-installed {raster}.


Here is the new session information:


R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8    LC_MONETARY=English_United Kingdom.utf8
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.utf8    

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

other attached packages:
[1] gdistance_1.6 Matrix_1.5-1  igraph_1.3.1  raster_3.6-13 sp_1.5-0     

loaded via a namespace (and not attached):
 [1] compiler_4.2.2   magrittr_2.0.3   rgdal_1.5-32     tools_4.2.2      rstudioapi_0.14  Rcpp_1.0.8.3     remotes_2.4.2   
 [8] codetools_0.2-18 grid_4.2.2       pkgconfig_2.0.3  lattice_0.20-45  terra_1.6-47   

Changes to attached packages present in each session:

  • gdistance_1.6 -> distance_1.6
  • Matrix_1.5-1 -> Matrix_1.5-1
  • igraph_1.3.5 -> igraph_1.3.1
  • raster_3.6-11 -> raster_3.6-13
  • sp_1.5-1 -> sp_1.5-0

Not sure where the exact source of the error message is yet though!

@kauedesousa
Copy link
Member

I have a hypothesis that this might be an issue in matching the S3 S4 methods for raster objects. I have a similar issue in another package ropensci/chirps#45 but I need to investigate a bit more.

@ZekeMarshall
Copy link
Author

Thanks for getting back to me @kauedesousa . Cool, let me know if you get to the bottom of this, i'll stick with the configuration of packages that works for now. Thanks again!

@andrewmarx
Copy link
Contributor

I'm going to go ahead and close this. I haven't encountered this issue, and I suspect (I haven't verified) the source might have been the terra package, which the raster package uses under the hood.

If anyone encounters this issue again, make sure that terra and raster are both updated. If it's still an issue after that, go ahead and open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants