After reading the post "Example optimisation fails", I have been trying to figure out why I get the message
Error in .local(.Object, ...) :
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file. (file does not exist)
in the gaOptimizeSegmentationParams() function. It is as follows:
gaOptim <- gaOptimizeSegmentationParams( rstFeatures = rstClassifFeatures, ## Type: stack
trainData = rstTrainData, # Type: S4 (loaded with function raster() )
# // Segmentation parameters ---
segmentMethod = "OTB_LSMS",
inputRstPath = segRaster, # I am testing with Sentinel-2 , so this is the same stac as rstFeatures.
otbBinPath = otbPath,
# Path to OTB exists
verbose = FALSE,
# // End segmentation parameters ---
trainThresh = 0.5,
segmStatsFuns = c("mean","sd"),
classificationMethod = "RF",
classificationMethodParams = NULL,
balanceTrainData = FALSE,
balanceMethod = "ubOver",
evalMethod = "10FCV",
evalMetric = "Kappa",
trainPerc = 0.6, #training proportion
minTrainCases = 15,
minCasesByClassTrain = 3,
minCasesByClassTest = 1,
minImgSegm = 4,
lower = OTB_min_params,
upper = OTB_max_params,
popSize = 10,
pcrossover = 0.9,
pmutation = 0.1,
maxiter = 5, # Number of iterations in a run
run = 4, # number of times running all the iterations
keepBest = TRUE,
parallel = FALSE,
bylayer = TRUE)
I have tried to change the file extension from .jp2 to .tif for Sentinel 2 images and still get the same message. Did anybody had the same problem?
Thank you.