Sunday, 26 August 2018

Make an optional input parameter in QGIS Processing Algorithm Script


My version of QGIS is 2.8.3


I have a tool which takes parameters like this:


##Input_Vector_Layer=vector
##Input_Raster_Layer=raster
##Distance=number 1.0

##Height=field Input_Vector_Layer

# Do Something...

Is it possible to make the fourth parameter optional?



Answer



If it's not a problem for you, my idea is to add a Boolean:


##Input_Vector_Layer=vector
##Input_Raster_Layer=raster
##Distance=number 1.0

##Height=field Input_Vector_Layer
##Use_Optional_Field=Boolean True

and the directly check for its value:


check = Use_Optional_Field
if check:
# Do something...
else:
# Do something else

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...