Error when running prepareCalData function

84 views
Skip to first unread message

Léo Rasse

unread,
Feb 28, 2022, 10:26:41 AM2/28/22
to SegOptim user group
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

João Gonçalves

unread,
Apr 11, 2022, 11:36:55 AM4/11/22
to SegOptim user group
Hi Léo,

Sorry for the delay... I think this issue is being triggered by the dtplyr package.
You can try to update it from GitHub which already includes a patch for this issue:

# install.packages("devtools")
devtools::install_github("tidyverse/dtplyr")

#And then also update SegOptim:
remotes::install_github("joaofgoncalves/SegOptim", ref="experimental")

Let me know if it works.
Cheers
João
Reply all
Reply to author
Forward
0 new messages