2013-09-24 22:06:50 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
lasoverlap.py
|
|
|
|
---------------------
|
|
|
|
Date : September 2013
|
|
|
|
Copyright : (C) 2013 by Martin Isenburg
|
|
|
|
Email : martin near rapidlasso point 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. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Martin Isenburg'
|
|
|
|
__date__ = 'September 2013'
|
|
|
|
__copyright__ = '(C) 2013, Martin Isenburg'
|
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
|
|
|
import os
|
2014-04-17 01:41:25 +02:00
|
|
|
from LAStoolsUtils import LAStoolsUtils
|
|
|
|
from LAStoolsAlgorithm import LAStoolsAlgorithm
|
2013-09-24 22:06:50 +02:00
|
|
|
|
2014-07-14 14:19:09 +02:00
|
|
|
from processing.core.parameters import ParameterBoolean
|
|
|
|
from processing.core.parameters import ParameterNumber
|
|
|
|
from processing.core.parameters import ParameterSelection
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
class lasoverlap(LAStoolsAlgorithm):
|
|
|
|
|
2014-05-19 19:58:33 +02:00
|
|
|
CHECK_STEP = "CHECK_STEP"
|
|
|
|
ATTRIBUTE = "ATTRIBUTE"
|
|
|
|
OPERATION = "OPERATION"
|
|
|
|
ATTRIBUTES = ["elevation", "intensity", "number_of_returns", "scan_angle_abs", "density"]
|
|
|
|
OPERATIONS = ["lowest", "highest", "average"]
|
|
|
|
CREATE_OVERLAP_RASTER = "CREATE_OVERLAP_RASTER"
|
|
|
|
CREATE_DIFFERENCE_RASTER = "CREATE_DIFFERENCE_RASTER"
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
def defineCharacteristics(self):
|
2015-07-26 03:48:27 +02:00
|
|
|
self.name, self.i18n_name = self.trAlgorithm('lasoverlap')
|
|
|
|
self.group, self.i18n_group = self.trAlgorithm('LAStools')
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseGUI()
|
|
|
|
self.addParametersPointInputGUI()
|
|
|
|
self.addParametersFilter1ReturnClassFlagsGUI()
|
2015-01-14 20:57:56 +02:00
|
|
|
self.addParameter(ParameterNumber(lasoverlap.CHECK_STEP,
|
|
|
|
self.tr("size of grid used for overlap check"), 0, None, 2.0))
|
|
|
|
self.addParameter(ParameterSelection(lasoverlap.ATTRIBUTE,
|
|
|
|
self.tr("attribute to check"), lasoverlap.ATTRIBUTES, 0))
|
|
|
|
self.addParameter(ParameterSelection(lasoverlap.OPERATION,
|
|
|
|
self.tr("operation on attribute per cell"), lasoverlap.OPERATIONS, 0))
|
|
|
|
self.addParameter(ParameterBoolean(lasoverlap.CREATE_OVERLAP_RASTER,
|
|
|
|
self.tr("create overlap raster"), True))
|
|
|
|
self.addParameter(ParameterBoolean(lasoverlap.CREATE_DIFFERENCE_RASTER,
|
|
|
|
self.tr("create difference raster"), True))
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersRasterOutputGUI()
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalGUI()
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
def processAlgorithm(self, progress):
|
2014-12-22 12:32:37 +01:00
|
|
|
commands = [os.path.join(LAStoolsUtils.LAStoolsPath(), "bin", "lasoverlap")]
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersVerboseCommands(commands)
|
|
|
|
self.addParametersPointInputCommands(commands)
|
|
|
|
self.addParametersFilter1ReturnClassFlagsCommands(commands)
|
|
|
|
step = self.getParameterValue(lasoverlap.CHECK_STEP)
|
|
|
|
if step != 0.0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-step")
|
2015-08-16 20:57:24 +02:00
|
|
|
commands.append(unicode(step))
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-values")
|
2013-09-24 22:06:50 +02:00
|
|
|
attribute = self.getParameterValue(lasoverlap.ATTRIBUTE)
|
|
|
|
if attribute != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-" + lasoverlap.ATTRIBUTES[attribute])
|
2013-09-24 22:06:50 +02:00
|
|
|
operation = self.getParameterValue(lasoverlap.OPERATION)
|
|
|
|
if operation != 0:
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-" + lasoverlap.OPERATIONS[operation])
|
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
|
|
|
if not self.getParameterValue(lasoverlap.CREATE_OVERLAP_RASTER):
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-no_over")
|
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
|
|
|
if not self.getParameterValue(lasoverlap.CREATE_DIFFERENCE_RASTER):
|
2014-05-19 19:58:33 +02:00
|
|
|
commands.append("-no_diff")
|
2013-09-24 22:06:50 +02:00
|
|
|
self.addParametersRasterOutputCommands(commands)
|
2014-12-22 12:32:37 +01:00
|
|
|
self.addParametersAdditionalCommands(commands)
|
2013-09-24 22:06:50 +02:00
|
|
|
|
|
|
|
LAStoolsUtils.runLAStools(commands, progress)
|