I want to make a simple if/else function inside my Model and I wanted to know if it's possible or not.
I want this thing to do that if an Input for 'Segment Layer' is selected that it doesn't have to execute the 'Segmentation(meanshift)' and uses 'Segment Layer' instead as an Input for the next Process.
the Inputs for the 'Segmentation(meanshift)'are as follows
Update after trying to implement Joseph's answer:
I used the following code and got this error
Update 2, after replacing the parameters I get an error in line 28 this is were 'else:' stands
##Example=name
##BGREN=optional raster
##Segment_Layer=optional vector
##output=output vector
if BGREN is not None:
processing.runalg('otb:segmentationmeanshift', \
-BGREN\
-0\
-70\
-70\
-0.1\
-100\
-100\
-0\
-0\
-0\
-'True'\
-'False'\
-1\
-0.1\
-'Layer'\
-'DN'\
-1024\
-1\
-0\
-output)
else:
output=Segment_Layer
Update it works :) after a few try's and with Joseph help this code now works like a charm, the final trick was to replace two optional values with 'None'.
##Example=name
##BGREN=optional raster
##Segment_Layer=optional vector
##output=output vector
if BGREN is not None:
processing.runalg('otb:segmentationmeanshift', \
BGREN, \
0, \
70, \
70, \
0.1, \
100, \
100, \
0, \
0, \
None, \
True, \
False, \
1, \
0.1, \
'Layer', \
'DN', \
1024, \
1, \
None, \
output)
else:
output=Segment_Layer