segmentation_OTB_LSMS isn't creating any outputfiles.

9 views
Skip to first unread message

Brandon Van Huizen

unread,
Aug 28, 2024, 3:48:34 PM8/28/24
to SegOptim user group
Hi there, I am attempting to run the segementation tool, however, when I go to load the segmented raster as a raster in R, it can't find it. I have checked all of my file paths, and they all seem to be correct. I saw someone else post with a similar problem, but they were using raster() which I don't think exists anymore, and rast() is the function I have to use. 

Below is my snippet of code
My.directory <-"C:/Users/brand/OneDrive - University of Waterloo/PostDoc/Waterloo/Projects"
setwd(My.directory)
Dinner_Raster<-rast("GIS_Data/Raster_Data/Dinner/DIN_Compositebands_1m.tif") # In this case, the raster is already a multiband raster, set to 1m resolution
outSegmRst<-segmentation_OTB_LSMS(SpectralRange = 3.1,SpatialRange = 4.5,MinSize = 21,
                                  inputRstPath =Dinner_Raster,
                                  outputSegmRst = "NAMP/ImageClassification/SegOutputs/segmRaster.tif",
                                  verbose=TRUE,
                                  otbBinPath = "C:/OTB/bin")
print(outSegmRst)
segmRst<-rast("NAMP/ImageClassification/SegOutputs/segmRaster.tif")
plot(segmRst)

João Gonçalves

unread,
Aug 29, 2024, 11:10:44 AM8/29/24
to Brandon Van Huizen, SegOptim user group

Dear Brandon,

Thanks for the feedback. The issue may be related to the use of cloud  folders in OneDrive. Other users have reported similar issues. Try to change the data to other location/folder with a simpler path in a local drive. Also avoiding spaces in paths is generally a good practice.
Try it and post back the error message if you find one.

Cheers
João


--
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 on the web visit https://groups.google.com/d/msgid/segoptim-user-group/7c1101a4-83be-4b10-bcee-8764847a6c60n%40googlegroups.com.

Brandon Van Huizen

unread,
Nov 14, 2024, 10:47:57 AM11/14/24
to SegOptim user group
Hi  João,

I still can't seem to get it to run. I moved everything to my Cdrive. If I execute the tool in powershell (command line) it does work, and creates a raster output at the end. It only seems to be when I am trying to run it within R. Below is the tool as I have it set up in R. The last three lines are it telling me what my SpectralRange, SpatialRange and MinSize are.  
outSegmRst<- segmentation_OTB_LSMS(inputRstPath = Dinner_Raster.3, + SpectralRange = 3, + SpatialRange = 10, + MinSize = 5, + tilesizex = 50, + tilesizey = 50, + lsms_maxiter = 50, + outputSegmRst = "SegOutputs/segmRaster.tif", + verbose = TRUE, + otbBinPath = otbPath) SpectralRange=3 SpatialRange=10 MinSize=5

João F Gonçalves

unread,
Nov 15, 2024, 11:05:06 AM11/15/24
to segoptim-...@googlegroups.com

Hi Brandon,

The outputs and preliminary files for the OTB segmentation will be placed on the working directory (or relative to it), so please check if you have defined these settings adequately in your script and file system.

As you may imagine, without being able to run a fully reproducible example in my side it is hard to assess/diagnose this issue. Can you provide this?

Btw, if the system is outputting this message:

SpectralRange=3 SpatialRange=10 MinSize=5

it means that SegOptim is actually segmenting the image with those parameters. So if no errors occur in OTB, the segmented image should be in the output location.


Cheers,

João

- -

Reply all
Reply to author
Forward
0 new messages