Skip to main content
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

Germán Carrillo'sGermán Carrillo's answer is the most convenient. A possible alternative (if you're stuck with QGIS 2.8) could be to:

  • Use a string which allows the user to enter the units they want to use:

      ##units=string mm
    
      if units == 'mm':
          # Do something
      elif units == 'cm':
          # Do something
      elif units == 'm':
          # Do something
    

Text units


  • Or use three boolean checkboxes:

      ##Millimeter=boolean
      ##Centimeter=boolean
      ##Meter=boolean
    
      if Millimeter == True:
          # Do something
      elif Centimeter == True:
          # Do something
      elif Meter == True:
          # Do something
    

Checkbox units

Germán Carrillo's answer is the most convenient. A possible alternative (if you're stuck with QGIS 2.8) could be to:

  • Use a string which allows the user to enter the units they want to use:

      ##units=string mm
    
      if units == 'mm':
          # Do something
      elif units == 'cm':
          # Do something
      elif units == 'm':
          # Do something
    

Text units


  • Or use three boolean checkboxes:

      ##Millimeter=boolean
      ##Centimeter=boolean
      ##Meter=boolean
    
      if Millimeter == True:
          # Do something
      elif Centimeter == True:
          # Do something
      elif Meter == True:
          # Do something
    

Checkbox units

Germán Carrillo's answer is the most convenient. A possible alternative (if you're stuck with QGIS 2.8) could be to:

  • Use a string which allows the user to enter the units they want to use:

      ##units=string mm
    
      if units == 'mm':
          # Do something
      elif units == 'cm':
          # Do something
      elif units == 'm':
          # Do something
    

Text units


  • Or use three boolean checkboxes:

      ##Millimeter=boolean
      ##Centimeter=boolean
      ##Meter=boolean
    
      if Millimeter == True:
          # Do something
      elif Centimeter == True:
          # Do something
      elif Meter == True:
          # Do something
    

Checkbox units

Source Link
Joseph
  • 76.3k
  • 7
  • 172
  • 286

Germán Carrillo's answer is the most convenient. A possible alternative (if you're stuck with QGIS 2.8) could be to:

  • Use a string which allows the user to enter the units they want to use:

      ##units=string mm
    
      if units == 'mm':
          # Do something
      elif units == 'cm':
          # Do something
      elif units == 'm':
          # Do something
    

Text units


  • Or use three boolean checkboxes:

      ##Millimeter=boolean
      ##Centimeter=boolean
      ##Meter=boolean
    
      if Millimeter == True:
          # Do something
      elif Centimeter == True:
          # Do something
      elif Meter == True:
          # Do something
    

Checkbox units