Skip to content
Permalink
Browse files

[processing] fix gdal_contour algorithm

(cherry picked from commit e4c1d89)

Conflicts:
	python/plugins/processing/algs/gdal/GdalUtils.py
  • Loading branch information
alexbruy committed Jun 22, 2016
1 parent d3d2603 commit 87789432577f3c231049999adc1f2aa400bc7709
Showing with 19 additions and 2 deletions.
  1. +13 −1 python/plugins/processing/algs/gdal/GdalUtils.py
  2. +6 −1 python/plugins/processing/algs/gdal/contour.py
@@ -29,7 +29,7 @@
import subprocess
import platform
from PyQt4.QtCore import QSettings
from qgis.core import QgsApplication
from qgis.core import QgsApplication, QgsVectorFileWriter
from processing.core.ProcessingLog import ProcessingLog

try:
@@ -130,6 +130,18 @@ def getSupportedRasterExtensions():
allexts.append(ext)
return allexts

@staticmethod
def getVectorDriverFromFileName(filename):
ext = os.path.splitext(filename)[1]
if ext == '':
return 'ESRI Shapefile'

formats = QgsVectorFileWriter.supportedFiltersAndFormats()
for k, v in formats.iteritems():
if ext in k:
return v
return 'ESRI Shapefile'

@staticmethod
def getFormatShortNameFromFilename(filename):
ext = filename[filename.rfind('.') + 1:]
@@ -62,6 +62,7 @@ def defineCharacteristics(self):
self.tr('Contours')))

def getConsoleCommands(self):
output = self.getOutputValue(self.OUTPUT_VECTOR)
interval = unicode(self.getParameterValue(self.INTERVAL))
fieldName = unicode(self.getParameterValue(self.FIELD_NAME))
extra = self.getParameterValue(self.EXTRA)
@@ -75,10 +76,14 @@ def getConsoleCommands(self):
arguments.append('-i')
arguments.append(interval)

driver = GdalUtils.getVectorDriverFromFileName(output)
arguments.append('-f')
arguments.append(driver)

if extra and len(extra) > 0:
arguments.append(extra)

arguments.append(self.getParameterValue(self.INPUT_RASTER))
arguments.append(self.getOutputValue(self.OUTPUT_VECTOR))
arguments.append(output)

return ['gdal_contour', GdalUtils.escapeAndJoin(arguments)]

0 comments on commit 8778943

Please sign in to comment.
You can’t perform that action at this time.