Hi João,
running your example data (and also my own data) with your tutorial code for parameter optimisation I am allways running in the below error message. Obvoiusly it is thrown by the GA package. As far as I understand all parameters are correctly passed through. Any suggestions are welcome.
best ChrisrstFeatures <- file.path(envrmt$path_segoptim,"SegmFeat_WV2_b532.tif")
trainData <- file.path(envrmt$path_segoptim,"TrainAreas.tif")
# 3 - start code
#-----------------
pyPath <- "C:/Anaconda3/envs/py35"
# Minimum values for nr of clusters, min segment size and spectral threshold
RSGISLib_Shep_min <- c(5, 10, 3)
# Maximum values for nr of clusters, min segment size and spectral threshold
RSGISLib_Shep_max <- c(12, 60, 40)
# Run the optimization procedure ----------------------------------------------------------------------------- #
gaOptim <- gaOptimizeSegmentationParams( rstFeatures = rstFeatures,
trainData = trainData,
# // Segmentation parameters ---
segmentMethod = "RSGISLib_Shep",
inputRstPath = envrmt$path_segoptim,
pythonPath = pyPath,
verbose = FALSE,
# // End segmentation parameters ---
trainThresh = 0.5,
segmStatsFuns = c("mean"),
classificationMethod = "RF",
classificationMethodParams = NULL,
balanceTrainData = FALSE,
balanceMethod = "ubOver",
evalMethod = "5FCV",
evalMetric = "Kappa",
minTrainCases = 30,
minCasesByClassTrain = 10,
minCasesByClassTest = 10,
minImgSegm = 30,
lower = RSGISLib_Shep_min,
upper = RSGISLib_Shep_max,
popSize = 20,
pcrossover = 0.8,
pmutation = 0.2,
maxiter = 100,
run = 20,
keepBest = TRUE,
parallel = 2) # us
GA | iter = 1 | Mean = NaN | Best = -Inf
GA | iter = 2 | Mean = NaN | Best = -Inf
Error in if (object@run >= run) break :
Missing value, where TRUE/FALSE is necessary
Additionally: Warning messages:
1: In max(fitness) :
no non-missing argument for max; return -Inf
2: In max(fitness, na.rm = TRUE) :
no non-missing argument for max; return -Inf
3: In max(fitness, na.rm = TRUE) :
no non-missing argument for max; return -Inf
4: In max(fitness) :
no non-missing argument for max; return -Inf
5: In max(fitness, na.rm = TRUE) :
no non-missing argument for max; return -Inf
6: In max(x, na.rm = TRUE) :
no non-missing argument for max; return -Inf
Error in gaOptimizeSegmentationParams(rstFeatures = rstFeatures, trainData = trainData, :
An error occurred while running ga function!sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] SegOptim_0.2.3 link2GI_0.4.3 envimaR_0.1.0
[4] SuperpixelImageSegmentation_1.0.1 OpenImageR_1.1.6 hrbrthemes_0.6.0
[7] ggrepel_0.8.1 scico_1.1.0 ggnewscale_0.4.1
[10] ggplot2_3.2.1 dplyr_0.8.4 here_0.1
[13] rnaturalearth_0.1.0 rgdal_1.4-8 sp_1.4-1
[16] stars_0.4-0 sf_0.8-1 abind_1.4-5
loaded via a namespace (and not attached):
[1] mlr_2.17.0 backports_1.1.5 fastmatch_1.1-0 systemfonts_0.1.1 lwgeom_0.2-1
[6] plyr_1.8.5 lazyeval_0.2.2 splines_3.6.1 crosstalk_1.0.0 leaflet_2.0.3
[11] usethis_1.5.1 digest_0.6.25 foreach_1.4.8 htmltools_0.4.0 tiff_0.1-5
[16] gdata_2.18.0 fansi_0.4.1 magrittr_1.5 checkmate_2.0.0 memoise_1.1.0
[21] BBmisc_1.11 unbalanced_2.0 cluster_2.1.0 doParallel_1.0.15 ROCR_1.0-7
[26] remotes_2.1.1 recipes_0.1.9 gower_0.2.1 extrafont_0.17 extrafontdb_1.0
[31] prettyunits_1.1.1 jpeg_0.1-8.1 colorspace_1.4-1 xfun_0.12 callr_3.4.2
[36] crayon_1.3.4 roxygen2_7.0.2 survival_2.44-1.1 iterators_1.0.12 glue_1.3.1
[41] gtable_0.3.0 cclust_0.6-21 ipred_0.9-9 webshot_0.5.2 pkgbuild_1.0.6
[46] Rttf2pt1_1.3.8 scales_1.1.0 uavRst_0.5-5 DBI_1.1.0 rngtools_1.5
[51] Rcpp_1.0.3 viridisLite_0.3.0 xtable_1.8-4 units_0.6-5 stats4_3.6.1
[56] lava_1.6.6 prodlim_2019.11.13 htmlwidgets_1.5.1 clusterCrit_1.2.8 FNN_1.1.3
[61] gplots_3.0.3 ellipsis_0.3.0 pkgconfig_2.0.3 ParamHelpers_1.13 nnet_7.3-12
[66] caret_6.0-85 reshape2_1.4.3 tidyselect_1.0.0 rlang_0.4.4 later_1.0.0
[71] munsell_0.5.0 tools_3.6.1 cli_2.0.2 generics_0.0.2 devtools_2.2.2
[76] evaluate_0.14 stringr_1.4.0 fastmap_1.0.1 ModelMetrics_1.2.2.1 processx_3.4.2
[81] knitr_1.28 fs_1.3.1 caTools_1.18.0 satellite_1.0.2 purrr_0.3.3
[86] randomForest_4.6-14 RANN_2.6.1 nlme_3.1-140 doRNG_1.8.2 mime_0.9
[91] GA_3.2 xml2_1.2.2 compiler_3.6.1 rstudioapi_0.11 curl_4.3
[96] png_0.1-7 e1071_1.7-3 testthat_2.3.1 tibble_2.1.3 stringi_1.4.6
[101] ps_1.3.2 desc_1.2.0 gdtools_0.2.1 lattice_0.20-38 Matrix_1.2-17
[106] classInt_0.4-2 gbm_2.1.5 pillar_1.4.3 lifecycle_0.1.0 data.table_1.12.8
[111] bitops_1.0-6 mapview_2.7.0 raster_3.0-12 httpuv_1.5.2 R6_2.4.1
[116] promises_1.1.0 KernSmooth_2.23-15 gridExtra_2.3 sessioninfo_1.1.1 codetools_0.2-16
[121] MASS_7.3-51.4 gtools_3.8.1 assertthat_0.2.1 pkgload_1.0.2 rprojroot_1.3-2
[126] withr_2.1.2 parallel_3.6.1 grid_3.6.1 rpart_4.1-15 timeDate_3043.102
[131] class_7.3-15 rmarkdown_2.1 mda_0.4-10 parallelMap_1.4 pROC_1.16.1
[136] base64enc_0.1-3 lubridate_1.7.4 shiny_1.4.0
{ fit <- do.call(fitness, c(list(Pop[i,]), callArgs))
SpectralRange=0.18225
SpatialRange=16.92107
MinSize=811.43608
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file. (file does not exist) rstFeatures = rstFeatures,
inputRstPath = envrmt$path_segoptim,
cheers Chris
are identical and point to the tif file.
Hi João.
all good things go by three - so sorry for bothering you.
Finally I managed it to identify the error. It was a code table issue from transferring script data from Linux to Win10 therefore whysoever the paths to the binaries were misinterpreted
and neither RSGISlib nor OTB binaries were found. The resulting error message was: "Cannot create a RasterLayer object from this file. (file does not exist)"...
So it's time to say thanks for the cool package!
cheers Chris
Hi João,
this posts were in parallel... Yes I have had checked your hints already. I finally found it debugging thru your package and checking the OTB wrapper commands and there was something like a hidden blank in the string. Acutally I don't now why. On this way I noticed that I should change the NAs too. So everything fine for now.
Thanks again!
Cheers
Thanks for the feedback Chris!
Let me know if you have any further question, bug report or feature request.
Cheers
- - -