|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | + |
| 3 | +""" |
| 4 | +*************************************************************************** |
| 5 | + gdal2xyz.py |
| 6 | + --------------------- |
| 7 | + Date : September 2013 |
| 8 | + Copyright : (C) 2013 by Alexander Bruy |
| 9 | + Email : alexander dot bruy at gmail dot com |
| 10 | +*************************************************************************** |
| 11 | +* * |
| 12 | +* This program is free software; you can redistribute it and/or modify * |
| 13 | +* it under the terms of the GNU General Public License as published by * |
| 14 | +* the Free Software Foundation; either version 2 of the License, or * |
| 15 | +* (at your option) any later version. * |
| 16 | +* * |
| 17 | +*************************************************************************** |
| 18 | +""" |
| 19 | + |
| 20 | +__author__ = 'Alexander Bruy' |
| 21 | +__date__ = 'September 2013' |
| 22 | +__copyright__ = '(C) 2013, Alexander Bruy' |
| 23 | +# This will get replaced with a git SHA1 when you do a git archive |
| 24 | +__revision__ = '$Format:%H$' |
| 25 | + |
| 26 | +import os |
| 27 | +from PyQt4.QtGui import * |
| 28 | +from PyQt4.QtCore import * |
| 29 | + |
| 30 | +from processing.core.GeoAlgorithm import GeoAlgorithm |
| 31 | + |
| 32 | +from processing.parameters.ParameterRaster import ParameterRaster |
| 33 | +from processing.parameters.ParameterNumber import ParameterNumber |
| 34 | +from processing.outputs.OutputTable import OutputTable |
| 35 | + |
| 36 | +from processing.tools.system import * |
| 37 | + |
| 38 | +from processing.gdal.GdalUtils import GdalUtils |
| 39 | + |
| 40 | +class gdal2xyz(GeoAlgorithm): |
| 41 | + |
| 42 | + INPUT = "INPUT" |
| 43 | + BAND = "BAND" |
| 44 | + OUTPUT = "OUTPUT" |
| 45 | + |
| 46 | + #def getIcon(self): |
| 47 | + # return QIcon(os.path.dirname(__file__) + "/icons/gdal2xyz.png") |
| 48 | + |
| 49 | + def defineCharacteristics(self): |
| 50 | + self.name = "gdal2xyz" |
| 51 | + self.group = "[GDAL] Conversion" |
| 52 | + self.addParameter(ParameterRaster(self.INPUT, "Input layer", False)) |
| 53 | + self.addParameter(ParameterNumber(self.BAND, "Band number", 1, 9999, 1)) |
| 54 | + |
| 55 | + self.addOutput(OutputTable(self.OUTPUT, "Output file")) |
| 56 | + |
| 57 | + def processAlgorithm(self, progress): |
| 58 | + arguments = [] |
| 59 | + arguments.append("-band") |
| 60 | + arguments.append(str(self.getParameterValue(self.BAND))) |
| 61 | + |
| 62 | + arguments.append("-csv") |
| 63 | + arguments.append(self.getParameterValue(self.INPUT)) |
| 64 | + arguments.append(self.getOutputValue(self.OUTPUT)) |
| 65 | + |
| 66 | + commands = [] |
| 67 | + if isWindows(): |
| 68 | + commands = ["cmd.exe", "/C ", "gdal2xyz.bat", GdalUtils.escapeAndJoin(arguments)] |
| 69 | + else: |
| 70 | + commands = ["gdal2xyz.py", GdalUtils.escapeAndJoin(arguments)] |
| 71 | + |
| 72 | + GdalUtils.runGdal(commands, progress) |
0 commit comments