mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[processing] fixed conversion to unsupported raster formats after running algorithm
This commit is contained in:
parent
61d81f01d5
commit
83782cc4c8
@ -17,6 +17,7 @@
|
||||
***************************************************************************
|
||||
"""
|
||||
|
||||
|
||||
__author__ = 'Victor Olaya'
|
||||
__date__ = 'August 2012'
|
||||
__copyright__ = '(C) 2012, Victor Olaya'
|
||||
@ -27,10 +28,11 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
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 @@ class GeoAlgorithm:
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user