Hi Ricardo,
Thanks for your feedback. Seems that you are having some problems fitting your imagery into memory while calculating statistics for each segment (more specifically the rstFeatures raster stack). Unfortunately, this is still an issue in SegOptim which relates to the need for speeding up some calculations in R.
To tackle this there are a couple of solutions but first, you have to make sure you have the experimental build of SegOptim installed (also better to perform a re-installation because of recent changes introduced). To do that run:
remotes::install_github("joaofgoncalves/SegOptim", ref="experimental")
Then, to manage memory issues you may use the following approaches:
i) (If you are using optimization of image segmentation parameters), try to use a smaller and representative subset area of your overall study site to run the optimization. That way less data is put into memory each time segment statistics are calculated;
ii)
(If you are using optimization of image segmentation parameters),
avoid using parallel processing because this will make things faster but consume much more memory (memory usage multiplies by the number of parallel workers, so keep that in mind);
iii) run segment statistics by layer, to do that, enable these options here:
calculateSegmentStats( <other_options>, bylayer=TRUE)
Or
gaOptimizeSegmentationParams(
<other_options>, bylayer=TRUE
)
iv) run segment statistics by tiles, which is the best way to reduce memory usage:
calculateSegmentStats( <other_options>, tiles = 3)
Or
gaOptimizeSegmentationParams(
<other_options>, tiles = 3)
This way your full raster stack in rstFeatures will be break up into smaller rectangular subsets (i.e. tiles) along the x and y axis. In the example above 3 x 3 = 9 tiles would be generated. The number of tiles must be set to avoid an excessively large number of tiles which would make processing very time-consuming.
Hope this helps. Let me know how it goes.