MK_dPCIIC function gives error
Closed this issue · 2 comments
Hi. I am getting the following warning/error when running the MK_dPCIIC function with two rasters:
old-style crs object detected; please recreate object with a recent sf::st_crs()
Error in stopf("Unsupported type of 'workers' for evaluator of class %s: %s", : Unsupported type of 'workers' for evaluator of class ‘FutureStrategy’, ‘tweaked’, ‘multiprocess’, ‘future’, ‘function’: logical
Here is the code I am running
MK_dPCIIC(nodes = r2C,
distance = list(type = "least-cost",
resistance = r1C,
mask = r2C),
attribute = NULL,
metric = "PC",
probability = 0.5,
distance_thresholds = 20500,
rasterparallel = T)
The projections of my rasters are:
+proj=utm +zone=17 +datum=WGS84 +units=m +no_defs
I have assigned PROJ6 new style using:
raster::crs(r1C) <- "EPSG:32617"
raster::crs(r2C) <- "EPSG:32617"
Any tips on how to solve this? I have installed Rtools4 as suggested as well as devtools and remotes.
Here is my system info:
R version 4.1.1 (2021-08-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19043)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] sf_1.0-6 raster_3.5-15 sp_1.4-5 Makurhini_2.0.4
[5] igraph_1.2.7 remotes_2.4.1 devtools_2.4.2 usethis_2.1.3
loaded via a namespace (and not attached):
[1] colorspace_2.0-2 ggsignif_0.6.3 ellipsis_0.3.2
[4] class_7.3-19 rio_0.5.27 rgdal_1.5-27
[7] rprojroot_2.0.2 fs_1.5.0 quadmesh_0.5.0
[10] rstudioapi_0.13 httpcode_0.3.0 proxy_0.4-26
[13] ggpubr_0.4.0 listenv_0.8.0 furrr_0.2.3
[16] fansi_0.5.0 codetools_0.2-18 cachem_1.0.6
[19] knitr_1.36 pkgload_1.2.3 geojsonlint_0.4.0
[22] jsonlite_1.7.2 reproj_0.4.2 broom_0.7.10
[25] png_0.1-7 rgeos_0.5-8 compiler_4.1.1
[28] backports_1.2.1 assertthat_0.2.1 Matrix_1.3-4
[31] fastmap_1.1.0 cli_3.1.0 htmltools_0.5.2
[34] prettyunits_1.1.1 tools_4.1.1 gtable_0.3.0
[37] glue_1.4.2 dplyr_1.0.7 V8_4.1.0
[40] Rcpp_1.0.7 carData_3.0-4 cellranger_1.1.0
[43] vctrs_0.3.8 crul_1.2.0 progressr_0.10.0
[46] xfun_0.26 globals_0.14.0 ps_1.6.0
[49] openxlsx_4.2.4 testthat_3.1.0 lifecycle_1.0.1
[52] rstatix_0.7.0 crsmeta_0.3.0 future_1.24.0
[55] terra_1.5-17 scales_1.1.1 hms_1.1.1
[58] proj4_1.0-11 parallel_4.1.1 graph4lg_1.2.0
[61] curl_4.3.2 memoise_2.0.0 ggplot2_3.3.5
[64] stringi_1.7.5 jsonvalidate_1.3.2 desc_1.4.0
[67] e1071_1.7-8 boot_1.3-28 pkgbuild_1.2.0
[70] zip_2.2.0 geometry_0.4.5 rlang_0.4.12
[73] pkgconfig_2.0.3 evaluate_0.14 lattice_0.20-44
[76] purrr_0.3.4 htmlwidgets_1.5.4 processx_3.5.2
[79] tidyselect_1.1.1 parallelly_1.30.0 magrittr_2.0.1
[82] R6_2.5.1 generics_0.1.1 DBI_1.1.1
[85] pillar_1.6.4 haven_2.4.3 foreign_0.8-81
[88] withr_2.4.2 units_0.7-2 spex_0.7.1
[91] abind_1.4-5 tibble_3.1.5 crayon_1.4.2
[94] car_3.0-11 rmapshaper_0.4.5 KernSmooth_2.23-20
[97] utf8_1.2.2 formattable_0.2.1 rmarkdown_2.11
[100] grid_4.1.1 readxl_1.3.1 data.table_1.14.2
[103] callr_3.7.0 forcats_0.5.1 digest_0.6.28
[106] classInt_0.4-3 gdistance_1.3-6 tidyr_1.1.4
[109] munsell_0.5.0 magic_1.6-0 sessioninfo_1.1.1
After removing "rasterparallel = T" I was able to run the function successfully.
Hello. Nice to read you and an apology for the delay in answering, I had some personal problems but I'm back.
It is good to know that the problem has been solved. "rasterparallel" is numeric and not logical. You have to specify the number of cores to use for parallel processing, default = NULL. It is useful when the raster resolution is less than 100 m2.
To find out how many cores you have available in your computer you can use:
library(future)
availableCores()
Less than the total number of available cores is usually used. For example:
as.numeric(availableCores())-1 #
round(as.numeric(availableCores())/2) #Half
The final number of cores is placed in rasterparallel, example:
MK_dPCIIC(nodes = r2C,
distance = list(type = "least-cost",
resistance = r1C,
mask = r2C),
attribute = NULL,
metric = "PC",
probability = 0.5,
distance_thresholds = 20500,
rasterparallel = 4)
Cheers,