Dear João,
I am currently working with SegOptim pakage to make an object-based classification. However, I got the following error when running the preparecalData function:
" --> [1/3] Loading train data into image segments...
Error : can't subset '.data' outside of a data mask context.
Error in getTrainData_(x = x, rstSegm = rstSegm, useThresh = useThresh, :
An error occured while calculating training data stats!"
I tried many ways to solve the problem but the error persist. Do you have an idea of a potential solution ?
Here is my script:
calData <- prepareCalData(rstSegm = segmRst, trainData = TrainData, rstFeatures = ClassificationFeatures, thresh = 0.7, funs = c('mean','sd'), minImgSegm = 30, verbose = T)
Where segmRst is the out raster of the segmentation_OTB_LSMS function ; TrainData is a raster layer where each object is a polygon having a value ranging from 1 to 8 (I want to have 8 final class) ; and ClassificationFeatures is a RasterStack layer with 14 Features.
Thanks in advance for your help,
Regards, Léo