|
17 | 17 | ***************************************************************************
|
18 | 18 | """
|
19 | 19 |
|
| 20 | + |
20 | 21 | __author__ = 'Victor Olaya'
|
21 | 22 | __date__ = 'August 2012'
|
22 | 23 | __copyright__ = '(C) 2012, Victor Olaya'
|
|
27 | 28 |
|
28 | 29 | import os.path
|
29 | 30 | import traceback
|
| 31 | +import subprocess |
30 | 32 | import copy
|
31 | 33 |
|
32 | 34 | from PyQt4.QtGui import QIcon
|
33 |
| -from PyQt4.QtCore import QCoreApplication |
| 35 | +from PyQt4.QtCore import QCoreApplication, QSettings |
34 | 36 | from qgis.core import QGis, QgsRasterFileWriter
|
35 | 37 |
|
36 | 38 | from processing.core.ProcessingLog import ProcessingLog
|
@@ -294,13 +296,31 @@ def convertUnsupportedFormats(self, progress):
|
294 | 296 | elif isinstance(out, OutputRaster):
|
295 | 297 | if out.compatible is not None:
|
296 | 298 | layer = dataobjects.getObjectFromUri(out.compatible)
|
297 |
| - provider = layer.dataProvider() |
298 |
| - writer = QgsRasterFileWriter(out.value) |
299 | 299 | format = self.getFormatShortNameFromFilename(out.value)
|
300 |
| - writer.setOutputFormat(format) |
301 |
| - writer.writeRaster(layer.pipe(), layer.width(), |
302 |
| - layer.height(), layer.extent(), |
303 |
| - layer.crs()) |
| 300 | + orgFile = out.compatible |
| 301 | + destFile = out.value |
| 302 | + crsid = layer.crs().authid() |
| 303 | + settings = QSettings() |
| 304 | + path = unicode(settings.value('/GdalTools/gdalPath', '')) |
| 305 | + envval = unicode(os.getenv('PATH')) |
| 306 | + if not path.lower() in envval.lower().split(os.pathsep): |
| 307 | + envval += '%s%s' % (os.pathsep, path) |
| 308 | + os.putenv('PATH', envval) |
| 309 | + command = 'gdal_translate -of %s -a_srs %s %s %s' % (format, crsid, orgFile, destFile) |
| 310 | + if os.name == 'nt': |
| 311 | + command = command.split(" ") |
| 312 | + else: |
| 313 | + command = [command] |
| 314 | + subprocess.Popen( |
| 315 | + command, |
| 316 | + shell=True, |
| 317 | + stdout=subprocess.PIPE, |
| 318 | + stdin=subprocess.PIPE, |
| 319 | + stderr=subprocess.STDOUT, |
| 320 | + universal_newlines=False, |
| 321 | + ) |
| 322 | + |
| 323 | + |
304 | 324 | elif isinstance(out, OutputTable):
|
305 | 325 | if out.compatible is not None:
|
306 | 326 | layer = dataobjects.getObjectFromUri(out.compatible)
|
|
0 commit comments