Skip to content
Permalink
Browse files

[processing] fixed conversion to unsupported raster formats after run…

…ning algorithm
  • Loading branch information
volaya committed Jun 22, 2015
1 parent 61d81f0 commit 83782cc4c8a0751f46ab485c9463975a57fa2b07
Showing with 27 additions and 7 deletions.
  1. +27 −7 python/plugins/processing/core/GeoAlgorithm.py
@@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
@@ -27,10 +28,11 @@

import os.path
import traceback
import subprocess
import copy

from PyQt4.QtGui import QIcon
from PyQt4.QtCore import QCoreApplication
from PyQt4.QtCore import QCoreApplication, QSettings
from qgis.core import QGis, QgsRasterFileWriter

from processing.core.ProcessingLog import ProcessingLog
@@ -294,13 +296,31 @@ def convertUnsupportedFormats(self, progress):
elif isinstance(out, OutputRaster):
if out.compatible is not None:
layer = dataobjects.getObjectFromUri(out.compatible)
provider = layer.dataProvider()
writer = QgsRasterFileWriter(out.value)
format = self.getFormatShortNameFromFilename(out.value)
writer.setOutputFormat(format)
writer.writeRaster(layer.pipe(), layer.width(),
layer.height(), layer.extent(),
layer.crs())
orgFile = out.compatible
destFile = out.value
crsid = layer.crs().authid()
settings = QSettings()
path = unicode(settings.value('/GdalTools/gdalPath', ''))
envval = unicode(os.getenv('PATH'))
if not path.lower() in envval.lower().split(os.pathsep):
envval += '%s%s' % (os.pathsep, path)
os.putenv('PATH', envval)
command = 'gdal_translate -of %s -a_srs %s %s %s' % (format, crsid, orgFile, destFile)
if os.name == 'nt':
command = command.split(" ")
else:
command = [command]
subprocess.Popen(
command,
shell=True,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=False,
)


elif isinstance(out, OutputTable):
if out.compatible is not None:
layer = dataobjects.getObjectFromUri(out.compatible)

0 comments on commit 83782cc

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