2013-09-30 16:14:56 +03:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
gdal2xyz.py
|
|
|
|
---------------------
|
|
|
|
Date : September 2013
|
|
|
|
Copyright : (C) 2013 by Alexander Bruy
|
|
|
|
Email : alexander dot bruy at gmail dot com
|
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
2016-09-21 18:24:26 +02:00
|
|
|
from builtins import str
|
2013-09-30 16:14:56 +03:00
|
|
|
|
|
|
|
__author__ = 'Alexander Bruy'
|
|
|
|
__date__ = 'September 2013'
|
|
|
|
__copyright__ = '(C) 2013, Alexander Bruy'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-09-30 16:14:56 +03:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2013-09-30 16:14:56 +03:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2014-06-02 00:35:49 +02:00
|
|
|
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterRaster
|
|
|
|
from processing.core.parameters import ParameterNumber
|
|
|
|
from processing.core.outputs import OutputTable
|
2013-09-30 16:14:56 +03:00
|
|
|
|
fix python pep8 warnings and fix some revealed errors
pep8 --ignore=E111,E128,E201,E202,E203,E211,E221,E222,E225,E226,E227,E231,E241,E261,E265,E272,E302,E303,E501,E701 \
--exclude="ui_*.py,debian/*,python/ext-libs/*" \
.
2015-02-01 14:15:42 +01:00
|
|
|
from processing.tools.system import isWindows
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2014-04-17 01:41:25 +02:00
|
|
|
from processing.algs.gdal.GdalUtils import GdalUtils
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2014-06-02 00:35:49 +02:00
|
|
|
class gdal2xyz(GdalAlgorithm):
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
INPUT = 'INPUT'
|
|
|
|
BAND = 'BAND'
|
|
|
|
OUTPUT = 'OUTPUT'
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2017-03-29 12:51:59 +10:00
|
|
|
def name(self):
|
|
|
|
return 'gdal2xyz'
|
|
|
|
|
|
|
|
def displayName(self):
|
|
|
|
return self.tr('gdal2xyz')
|
|
|
|
|
2017-03-29 12:04:09 +10:00
|
|
|
def group(self):
|
|
|
|
return self.tr('Raster conversion')
|
|
|
|
|
2013-09-30 16:14:56 +03:00
|
|
|
def defineCharacteristics(self):
|
2015-01-13 10:49:08 +02:00
|
|
|
self.addParameter(ParameterRaster(
|
|
|
|
self.INPUT, self.tr('Input layer'), False))
|
|
|
|
self.addParameter(ParameterNumber(self.BAND,
|
2015-08-22 14:29:41 +02:00
|
|
|
self.tr('Band number'), 1, 9999, 1))
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2015-04-10 09:44:20 +02:00
|
|
|
self.addOutput(OutputTable(self.OUTPUT, self.tr('xyz')))
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2015-05-07 13:14:01 +02:00
|
|
|
def getConsoleCommands(self):
|
2013-09-30 16:14:56 +03:00
|
|
|
arguments = []
|
2013-10-01 20:52:22 +03:00
|
|
|
arguments.append('-band')
|
2016-09-21 18:24:26 +02:00
|
|
|
arguments.append(str(self.getParameterValue(self.BAND)))
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2013-10-01 20:52:22 +03:00
|
|
|
arguments.append('-csv')
|
2013-09-30 16:14:56 +03:00
|
|
|
arguments.append(self.getParameterValue(self.INPUT))
|
|
|
|
arguments.append(self.getOutputValue(self.OUTPUT))
|
|
|
|
|
|
|
|
commands = []
|
|
|
|
if isWindows():
|
2013-10-01 20:52:22 +03:00
|
|
|
commands = ['cmd.exe', '/C ', 'gdal2xyz.bat',
|
|
|
|
GdalUtils.escapeAndJoin(arguments)]
|
2013-09-30 16:14:56 +03:00
|
|
|
else:
|
2013-10-01 20:52:22 +03:00
|
|
|
commands = ['gdal2xyz.py', GdalUtils.escapeAndJoin(arguments)]
|
2013-09-30 16:14:56 +03:00
|
|
|
|
2015-05-21 15:43:47 +02:00
|
|
|
return commands
|