Skip to content
Permalink
Browse files

[processing] fix gdal_contour algorithm

  • Loading branch information
alexbruy committed Jun 22, 2016
1 parent f645b79 commit e4c1d896e97952743ea1c0c2144e33983fa5706a
Showing with 22 additions and 2 deletions.
  1. +14 −1 python/plugins/processing/algs/gdal/GdalUtils.py
  2. +8 −1 python/plugins/processing/algs/gdal/contour.py
@@ -29,7 +29,7 @@
import subprocess
import platform
from qgis.PyQt.QtCore import QSettings
from qgis.core import QgsApplication
from qgis.core import QgsApplication, QgsVectorFileWriter
from processing.core.ProcessingLog import ProcessingLog
from processing.core.SilentProgress import SilentProgress

@@ -142,6 +142,19 @@ 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():
print k, v
if ext in k:
return v
return 'ESRI Shapefile'

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

def getConsoleCommands(self):
output = self.getOutputValue(self.OUTPUT_VECTOR)
print 'OUTPUT', output
interval = unicode(self.getParameterValue(self.INTERVAL))
fieldName = unicode(self.getParameterValue(self.FIELD_NAME))
extra = self.getParameterValue(self.EXTRA)
@@ -84,10 +86,15 @@ def getConsoleCommands(self):
arguments.append('-i')
arguments.append(interval)

driver = GdalUtils.getVectorDriverFromFileName(output)
print 'DRIVER', driver
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 e4c1d89

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