Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] fixed conversion to unsupported raster formats after run…
…ning algorithm
  • Loading branch information
volaya committed Jun 22, 2015
1 parent 61d81f0 commit 83782cc
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -17,6 +17,7 @@
***************************************************************************
"""


__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 83782cc

Please sign in to comment.