RSGISLIB Optimization Error

34 views
Skip to first unread message

Mohammad javad Soltani

unread,
Jan 14, 2025, 4:52:35 AMJan 14
to SegOptim user group
Dear João 
First of all, i must admire your great work on optimization of segmentation!

on 'gaOptimizeSegmentationParams' I Accur this Error:
NumClust=54.77186 MinSize=34.29244 SpectralThresh=0.0669 Error in (function (cond) : error in evaluating the argument 'x' in selecting a method for function 'rast': subscript out of bounds In addition: Warning messages: 1: In (function (x, rstFeatures, trainData, segmentMethod, ..., trainThresh = 0.5, : An error occurred while trying to load the segmentation raster! 2: In shell(tmpBatchFile, ignore.stdout = TRUE, ignore.stderr = TRUE, : 'F:/My_Thesis/RSGISLib_Shep_Segm_6mibp95o.bat' execution failed with error code 1 GA | iter = 2 | Mean = NaN | Best = -Inf Error in if (object@run >= run) break : missing value where TRUE/FALSE needed In addition: Warning messages: 1: In (function (x, rstFeatures, trainData, segmentMethod, ..., trainThresh = 0.5, : An error occurred while trying to load the segmentation raster! 2: In max(Fitness, na.rm = TRUE) : no non-missing arguments to max; returning -Inf 3: In max(fitness) : no non-missing arguments to max; returning -Inf 4: In max(x, na.rm = TRUE) : no non-missing arguments to max; returning -Inf Error in gaOptimizeSegmentationParams(rstFeatures = rstClassifFeatures, : An error occurred while running ga function!
While:
1. parallel = FALSE
2. python == 3.5 and rsgislib = 3.4.9

I don't believe the issues are related to the min-max of my parameters, as I've tried various values and consistently encounter errors at an alarming rate, preventing any chance of starting the segmentation process. It would be great if we could segment using the package and debug before optimization phase.

Thanks in advance!
Cheers!

João F Gonçalves

unread,
Jan 15, 2025, 1:33:54 PMJan 15
to Mohammad javad Soltani, SegOptim user group

Dear Mohammad,

Thanks for the kind feedback on the package.

Regarding the optimization with RSGISLib I haven't been working with this software for a while now, so I need to check and prepare a testing environment for it.

Meanwhile could you please provide me a reproducible example with your code and data (a sample is enough) to go through the debugging?


Best regards,

João

- - -

Mohammad javad Soltani wrote:
--
You received this message because you are subscribed to the Google Groups "SegOptim user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to segoptim-user-g...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/segoptim-user-group/22e179c4-7447-4575-91de-be9dde7cabbfn%40googlegroups.com.
--

João Gonçalves | Post-doc researcher

InBIO - Research Network in Biodiversity and Evolutionary Biology, Associate Laboratory

CIBIO - Research Center in Biodiversity and Genetic Resources

BIOPOLIS - Program in Genomics, Biodiversity and Land Planning

ECOCHANGE - Predicting and Managing Ecological Change group

University of Porto, Campus Agrário de Vairão

4485-601 Vairão, Portugal | Tel. +351 252 660 411

ResearchGate | Google Scholar | GitHub | BitBucket

Message has been deleted
Message has been deleted

Mohammad javad Soltani

unread,
Jan 18, 2025, 7:27:42 AMJan 18
to SegOptim user group
Dear  João
So sorry for the slow reply.
Hope you are doing well. 

I have a 12 band max monthly NDVI image to input segmentation:
class : RasterStack dimensions : 882, 872, 769104, 12 (nrow, ncol, ncell, nlayers) resolution : 8.983153e-05, 8.983153e-05 (x, y) extent : 48.71447, 48.7928, 33.75653, 33.83576 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs names : NDVI_jan, NDVI_feb, NDVI_mar, NDVI_apr, NDVI_may, NDVI_jun, NDVI_jul, NDVI_aug, NDVI_sep, NDVI_ouc, NDVI_nov, NDVI_dec

and a 570 bands image to input for classification process: class : RasterStack dimensions : 882, 720, 635040, 570 (nrow, ncol, ncell, nlayers) resolution : 10, 10 (x, y) extent : 288430, 295630, 3737420, 3746240 (xmin, xmax, ymin, ymax) crs : +proj=utm +zone=39 +datum=WGS84 +units=m +no_defs  

and finally a tif, get valued by classes:
  class : RasterLayer dimensions : 792, 783, 620136 (nrow, ncol, ncell) resolution : 1e-04, 1e-04 (x, y) extent : 48.71447, 48.79277, 33.75653, 33.83573 (xmin, xmax, ymin, ymax) crs : +proj=longlat +datum=WGS84 +no_defs source : Ref_Rast1.tif names : LAYER values : 1, 13 (min, max) attributes : ID LAYER from: 1 Wheat-polygon to : 13 Mixed_TP-polygon 

Thanks in advance.
Javad

João Gonçalves

unread,
Jan 21, 2025, 11:15:37 AMJan 21
to SegOptim user group
Hi Javad,

Consider simplifying the inputs for the image segmentation step and providing a multiband raster for RSGISLib instead of a raster stack (which works better). On the other hand, consider the range of values in your input images, as this may affect how the parameters are set for the segmentation using RSGISLib. Often these algorithms are ready for for reflectance values in [0, 1] decimal range or expecting integer DNs (used for instance in aerial images or raw satellite images). Using NDVIs with negative range (although not very common) may potentially complicate the analysis.

Also, consider simplifying your input features for classification. Those 570 dimensions may bear substantial collinearity. Doing correlation analysis, VIF, PCA (or other better dimensionality reducers) and feature selection (so many algos out there?!... iterative selection/elimination, boruta, etc).

Cheers
João
Reply all
Reply to author
Forward
0 new messages