Open IbrahimUWA opened 9 months ago
Hi.. @IbrahimUWA, Try this. It will work.
classification<-fieldSegment(mosaic = Test, trainDataset = training_sam)
FIELDimageR.Extra utilizes terra library for raster operations. For more information about the functionalities of FIELDimageR.Extra and its dependencies, please refer to this publication: https://acsess.onlinelibrary.wiley.com/doi/full/10.1002/ppj2.20083
Hello, Previously, I tried all the classification methods as mentioned on your Github and that worked. However, I am trying the supervised method using Random forest and I get the following error consistantly. Please help me out regarding this issue. It will be highly appreciated. Thank you.
Error: classification<-fieldSegment(mosaic = Test, trainDataset = training_sam) [1] "Starting supervised classification ..." Error in predict.randomForest(modelFit, newdata) : variables in the training data missing in newdata
Code:
soil<-fieldView(mosaic = Test, editor = TRUE) soil<-st_as_sf(st_sample(soil, 200)) soil$class<-'soil'
plants<-fieldView(mosaic = Test, editor = TRUE) plants<-st_as_sf(st_sample(plants, 200)) plants$class<-'plants'
training_sam<-rbind(soil,plants)
classification<-fieldSegment(mosaic = raster(Test), trainDataset = training_sam)