mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
[processing] more changes to fusion lidar algorithms
This commit is contained in:
parent
b44a256b68
commit
dd8dbc23da
81
python/plugins/processing/algs/lidar/fusion/ASCII2DTM.py
Normal file
81
python/plugins/processing/algs/lidar/fusion/ASCII2DTM.py
Normal file
@ -0,0 +1,81 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
ASCII2DTM.py
|
||||
---------------------
|
||||
Date : May 2014
|
||||
Copyright : (C) 2014 by Niccolo' Marchi
|
||||
Email : sciurusurbanus at hotmail dot it
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = "Niccolo' Marchi"
|
||||
__date__ = 'May 2014'
|
||||
__copyright__ = "(C) 2014 by Niccolo' Marchi"
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from processing.parameters.ParameterFile import ParameterFile
|
||||
from processing.parameters.ParameterSelection import ParameterSelection
|
||||
from processing.parameters.ParameterNumber import ParameterNumber
|
||||
from processing.outputs.OutputFile import OutputFile
|
||||
from FusionAlgorithm import FusionAlgorithm
|
||||
from FusionUtils import FusionUtils
|
||||
|
||||
|
||||
class ASCII2DTM(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
COORDSYS = 'COORDSYS'
|
||||
XYUNITS = 'XYUNITS'
|
||||
ZUNITS = 'ZUNITS'
|
||||
UNITS = ['Meter', 'Feet']
|
||||
ZONE = 'ZONE'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'ASCII to DTM'
|
||||
self.group = 'Conversion'
|
||||
self.addParameter(ParameterFile(self.INPUT, 'Input ESRI ASCII layer'))
|
||||
self.addParameter(ParameterSelection(self.XYUNITS, 'XY Units',
|
||||
self.UNITS))
|
||||
self.addParameter(ParameterSelection(self.ZUNITS, 'Z Units',
|
||||
self.UNITS))
|
||||
self.addParameter(ParameterSelection(self.COORDSYS, 'Coordinate system',
|
||||
['unknown', 'UTM', 'state plane']))
|
||||
self.addParameter(ParameterNumber(self.ZONE, "Coordinate system zone ('0' for unknown)", 0, None,
|
||||
0))
|
||||
self.addOutput(OutputFile(self.OUTPUT, 'Output surface', 'dtm'))
|
||||
self.addAdvancedModifiers()
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'ASCII2DTM.exe')]
|
||||
commands.append('/verbose')
|
||||
self.addAdvancedModifiersToCommand(commands)
|
||||
outFile = self.getOutputValue(self.OUTPUT)
|
||||
commands.append(outFile)
|
||||
commands.append(self.UNITS[self.getParameterValue(self.XYUNITS)][0])
|
||||
commands.append(self.UNITS[self.getParameterValue(self.ZUNITS)][0])
|
||||
commands.append(str(self.getParameterValue(self.COORDSYS)))
|
||||
commands.append(str(self.getParameterValue(self.ZONE)))
|
||||
commands.append('0')
|
||||
commands.append('0')
|
||||
files = self.getParameterValue(self.INPUT).split(';')
|
||||
if len(files) == 1:
|
||||
commands.append(self.getParameterValue(self.INPUT))
|
||||
else:
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
FusionUtils.runFusion(commands, progress)
|
@ -26,11 +26,14 @@ __copyright__ = '(C) 2012, Victor Olaya'
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
from PyQt4 import QtGui
|
||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
||||
from processing.parameters.ParameterFile import ParameterFile
|
||||
from processing.parameters.ParameterNumber import ParameterNumber
|
||||
from processing.parameters.ParameterBoolean import ParameterBoolean
|
||||
from processing.outputs.OutputTable import OutputTable
|
||||
from FusionUtils import FusionUtils
|
||||
from FusionAlgorithm import FusionAlgorithm
|
||||
from fusion.FusionUtils import FusionUtils
|
||||
from fusion.FusionAlgorithm import FusionAlgorithm
|
||||
|
||||
|
||||
class CanopyMaxima(FusionAlgorithm):
|
||||
@ -39,24 +42,41 @@ class CanopyMaxima(FusionAlgorithm):
|
||||
OUTPUT = 'OUTPUT'
|
||||
THRESHOLD = 'THRESHOLD'
|
||||
GROUND = 'GROUND'
|
||||
SUMMARY = 'SUMMARY'
|
||||
PARAM_A = 'PARAM_A'
|
||||
PARAM_C = 'PARAM_C'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'Canopy Maxima'
|
||||
self.group = 'Points'
|
||||
self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
|
||||
self.addParameter(ParameterFile(self.GROUND,
|
||||
'Input ground DTM layer [optional, leave blank if not using it]'))
|
||||
self.addParameter(ParameterNumber(self.THRESHOLD, 'Minimum threshold',
|
||||
self.addParameter(ParameterFile(self.INPUT, 'Input FUSION canopy height model'))
|
||||
self.addParameter(ParameterFile(self.GROUND, 'Input ground .dtm layer [optional]'))
|
||||
self.addParameter(ParameterNumber(self.THRESHOLD, 'Height threshold',
|
||||
0, None, 10.0))
|
||||
### begin
|
||||
self.addParameter(ParameterNumber(self.PARAM_A, 'Variable window size: parameter A',
|
||||
0, None, 2.51503))
|
||||
self.addParameter(ParameterNumber(self.PARAM_C, 'Parameter C',
|
||||
0, None, 0.00901))
|
||||
self.addParameter(ParameterBoolean(self.SUMMARY, 'Summary (tree height summary statistics)',
|
||||
False))
|
||||
### end
|
||||
self.addOutput(OutputTable(self.OUTPUT, 'Output file with maxima'))
|
||||
self.addAdvancedModifiers()
|
||||
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'CanopyMaxima.exe')]
|
||||
commands.append('/verbose')
|
||||
### begin
|
||||
commands.append('/wse:' + str(self.getParameterValue(self.PARAM_A)) + ',0,' + str(self.getParameterValue(self.PARAM_C)) + ',0')
|
||||
if self.getParameterValue(self.SUMMARY) == True:
|
||||
commands.append('/summary')
|
||||
### end
|
||||
self.addAdvancedModifiersToCommand(commands)
|
||||
ground = self.getParameterValue(self.GROUND)
|
||||
if str(ground).strip() != '':
|
||||
## here it's necessary to have the support for multiple files like for INPUT.
|
||||
if str(ground).strip():
|
||||
commands.append('/ground:' + str(ground))
|
||||
commands.append('/threshold:'
|
||||
+ str(self.getParameterValue(self.THRESHOLD)))
|
||||
|
@ -43,7 +43,6 @@ class CanopyModel(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT_DTM = 'OUTPUT_DTM'
|
||||
OUTPUT_ASCII = 'OUTPUT_ASCII'
|
||||
CELLSIZE = 'CELLSIZE'
|
||||
XYUNITS = 'XYUNITS'
|
||||
ZUNITS = 'ZUNITS'
|
||||
@ -53,7 +52,6 @@ class CanopyModel(FusionAlgorithm):
|
||||
SMOOTH = 'SMOOTH'
|
||||
SLOPE = 'SLOPE'
|
||||
CLASS = 'CLASS'
|
||||
ASCII = 'ASCII'
|
||||
ADVANCED_MODIFIERS = 'ADVANCED_MODIFIERS'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
@ -63,22 +61,20 @@ class CanopyModel(FusionAlgorithm):
|
||||
self.addParameter(ParameterNumber(self.CELLSIZE, 'Cellsize', 0, None, 10.0))
|
||||
self.addParameter(ParameterSelection(self.XYUNITS, 'XY Units', self.UNITS))
|
||||
self.addParameter(ParameterSelection(self.ZUNITS, 'Z Units', self.UNITS))
|
||||
self.addParameter(ParameterBoolean(self.ASCII, 'ASCII Output?'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_DTM, 'DTM Output Surface', 'dtm'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_ASCII, 'ASCII Output Surface', 'asc'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_DTM, 'DTM Output Surface', 'dtm'))
|
||||
ground = ParameterFile(self.GROUND, 'Input ground DTM layer', False, True)
|
||||
ground.isAdvanced = True
|
||||
self.addParameter(ground)
|
||||
median = ParameterString(self.MEDIAN, 'Median (set blank if not used)', '', False, True)
|
||||
median = ParameterString(self.MEDIAN, 'Median', '', False, True)
|
||||
median.isAdvanced = True
|
||||
self.addParameter(median)
|
||||
smooth = ParameterString(self.SMOOTH, 'Smooth (set blank if not used)', '', False, True)
|
||||
smooth = ParameterString(self.SMOOTH, 'Smooth', '', False, True)
|
||||
smooth.isAdvanced = True
|
||||
self.addParameter(smooth)
|
||||
slope = ParameterString(self.SLOPE, 'Slope (set blank if not used)', '', False, True)
|
||||
slope = ParameterString(self.SLOPE, 'Slope', '', False, True)
|
||||
slope.isAdvanced = True
|
||||
self.addParameter(slope)
|
||||
class_var = ParameterString(self.CLASS, 'Class (set blank if not used)', '', False, True)
|
||||
class_var = ParameterString(self.CLASS, 'Class', '', False, True)
|
||||
class_var.isAdvanced = True
|
||||
self.addParameter(class_var)
|
||||
advance_modifiers = ParameterString(self.ADVANCED_MODIFIERS, 'Additional modifiers', '', False, True)
|
||||
@ -89,23 +85,23 @@ class CanopyModel(FusionAlgorithm):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'CanopyModel.exe')]
|
||||
commands.append('/verbose')
|
||||
ground = self.getParameterValue(self.GROUND)
|
||||
if str(ground).strip() != '':
|
||||
if str(ground).strip():
|
||||
commands.append('/ground:' + str(ground))
|
||||
median = self.getParameterValue(self.MEDIAN)
|
||||
if str(median).strip() != '':
|
||||
if str(median).strip():
|
||||
commands.append('/median:' + str(median))
|
||||
smooth = self.getParameterValue(self.SMOOTH)
|
||||
if str(smooth).strip() != '':
|
||||
if str(smooth).strip():
|
||||
commands.append('/smooth:' + str(smooth))
|
||||
slope = self.getParameterValue(self.SLOPE)
|
||||
if str(slope).strip() != '':
|
||||
if str(slope).strip():
|
||||
commands.append('/slope:' + str(slope))
|
||||
class_var = self.getParameterValue(self.CLASS)
|
||||
if str(class_var).strip() != '':
|
||||
if str(class_var).strip():
|
||||
commands.append('/class:' + str(class_var))
|
||||
advance_modifiers = str(self.getParameterValue(self.ADVANCED_MODIFIERS)).strip()
|
||||
if advance_modifiers != '':
|
||||
commands.append(s)
|
||||
if advance_modifiers:
|
||||
commands.append(advance_modifiers)
|
||||
commands.append(self.getOutputValue(self.OUTPUT_DTM))
|
||||
commands.append(str(self.getParameterValue(self.CELLSIZE)))
|
||||
commands.append(self.UNITS[self.getParameterValue(self.XYUNITS)][0])
|
||||
@ -121,10 +117,3 @@ class CanopyModel(FusionAlgorithm):
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
FusionUtils.runFusion(commands, progress)
|
||||
ascii = self.getParameterValue(self.ASCII)
|
||||
if ascii == 1:
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'DTM2ASCII.exe')]
|
||||
commands.append(self.getOutputValue(self.OUTPUT_DTM))
|
||||
commands.append(self.getOutputValue(self.OUTPUT_ASCII))
|
||||
p = subprocess.Popen(commands, shell=True)
|
||||
p.wait()
|
||||
|
62
python/plugins/processing/algs/lidar/fusion/DTM2TIF.py
Normal file
62
python/plugins/processing/algs/lidar/fusion/DTM2TIF.py
Normal file
@ -0,0 +1,62 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
DTM2TIF.py
|
||||
---------------------
|
||||
Date : May 2014
|
||||
Copyright : (C) 2014 by Niccolo' Marchi
|
||||
Email : sciurusurbanus at hotmail dot it
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = "Niccolo' Marchi"
|
||||
__date__ = 'May 2014'
|
||||
__copyright__ = "(C) 2014 by Niccolo' Marchi"
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
from processing.parameters.ParameterFile import ParameterFile
|
||||
from processing.outputs.OutputRaster import OutputRaster
|
||||
from FusionAlgorithm import FusionAlgorithm
|
||||
from FusionUtils import FusionUtils
|
||||
|
||||
|
||||
class DTM2TIF(FusionAlgorithm):
|
||||
|
||||
INPUT = "INPUT"
|
||||
OUTPUT = "OUTPUT"
|
||||
CSV = 'CSV'
|
||||
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = "DTM to TIF"
|
||||
self.group = "Conversion"
|
||||
self.addParameter(ParameterFile(self.INPUT, "Input .dtm layer"))
|
||||
self.addOutput(OutputRaster(self.OUTPUT, 'Output file name'))
|
||||
self.addAdvancedModifiers()
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), "DTM2TIF.exe")]
|
||||
commands.append("/verbose")
|
||||
self.addAdvancedModifiersToCommand(commands)
|
||||
files = self.getParameterValue(self.INPUT).split(";")
|
||||
if len(files) == 1:
|
||||
commands.append(self.getParameterValue(self.INPUT))
|
||||
else:
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
outFile = self.getOutputValue(self.OUTPUT)
|
||||
commands.append(outFile)
|
||||
|
||||
FusionUtils.runFusion(commands, progress)
|
@ -0,0 +1,65 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
FirstLastReturn.py
|
||||
---------------------
|
||||
Date : May 2014
|
||||
Copyright : (C) 2014 by Niccolo' Marchi
|
||||
Email : sciurusurbanus at hotmail dot it
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = "Niccolo' Marchi"
|
||||
__date__ = 'May 2014'
|
||||
__copyright__ = "(C) 2014 by Niccolo' Marchi"
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
from processing.parameters.ParameterFile import ParameterFile
|
||||
from processing.parameters.ParameterBoolean import ParameterBoolean
|
||||
from processing.outputs.OutputFile import OutputFile
|
||||
from FusionAlgorithm import FusionAlgorithm
|
||||
from FusionUtils import FusionUtils
|
||||
|
||||
|
||||
class FirstLastReturn(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
SWITCH = 'SWITCH'
|
||||
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'First&Last Return'
|
||||
self.group = 'Points'
|
||||
self.addParameter(ParameterFile(self.INPUT, 'Input .las'))
|
||||
self.addParameter(ParameterBoolean(self.SWITCH, 'Use LAS info', True))
|
||||
self.addOutput(OutputFile(self.OUTPUT, 'Output layers'))
|
||||
self.addAdvancedModifiers()
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'FirstLastReturn.exe')]
|
||||
commands.append('/verbose')
|
||||
if self.getParameterValue(self.SWITCH) == True:
|
||||
commands.append('/uselas')
|
||||
self.addAdvancedModifiersToCommand(commands)
|
||||
outFile = self.getOutputValue(self.OUTPUT)
|
||||
commands.append(outFile)
|
||||
files = self.getParameterValue(self.INPUT).split(';')
|
||||
if len(files) == 1:
|
||||
commands.append(self.getParameterValue(self.INPUT))
|
||||
else:
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
FusionUtils.runFusion(commands, progress)
|
@ -43,7 +43,6 @@ class GridSurfaceCreate(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT_DTM = 'OUTPUT_DTM'
|
||||
OUTPUT_ASCII = 'OUTPUT_ASCII'
|
||||
CELLSIZE = 'CELLSIZE'
|
||||
XYUNITS = 'XYUNITS'
|
||||
ZUNITS = 'ZUNITS'
|
||||
@ -54,7 +53,6 @@ class GridSurfaceCreate(FusionAlgorithm):
|
||||
SLOPE = 'SLOPE'
|
||||
MINIMUM = 'MINIMUM'
|
||||
CLASS = 'CLASS'
|
||||
ASCII = 'ASCII'
|
||||
ADVANCED_MODIFIERS = 'ADVANCED_MODIFIERS'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
@ -64,25 +62,23 @@ class GridSurfaceCreate(FusionAlgorithm):
|
||||
self.addParameter(ParameterNumber(self.CELLSIZE, 'Cellsize', 0, None, 10.0))
|
||||
self.addParameter(ParameterSelection(self.XYUNITS, 'XY Units', self.UNITS))
|
||||
self.addParameter(ParameterSelection(self.ZUNITS, 'Z Units', self.UNITS))
|
||||
self.addParameter(ParameterBoolean(self.ASCII, 'ASCII Output?'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_DTM, 'DTM Output Surface', 'dtm'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_ASCII, 'ASCII Output Surface', 'asc'))
|
||||
spike = ParameterString(self.SPIKE, 'Spike (set blank if not used)', '', False, True)
|
||||
spike.isAdvanced = True
|
||||
self.addParameter(spike)
|
||||
median = ParameterString(self.MEDIAN, 'Median (set blank if not used)', '', False, True)
|
||||
median = ParameterString(self.MEDIAN, 'Median', '', False, True)
|
||||
median.isAdvanced = True
|
||||
self.addParameter(median)
|
||||
smooth = ParameterString(self.SMOOTH, 'Smooth (set blank if not used)', '', False, True)
|
||||
smooth = ParameterString(self.SMOOTH, 'Smooth', '', False, True)
|
||||
smooth.isAdvanced = True
|
||||
self.addParameter(smooth)
|
||||
slope = ParameterString(self.SLOPE, 'Slope (set blank if not used)', '', False, True)
|
||||
slope = ParameterString(self.SLOPE, 'Slope', '', False, True)
|
||||
slope.isAdvanced = True
|
||||
self.addParameter(slope)
|
||||
minimum = ParameterBoolean(self.MINIMUM, 'Minimum (set blank if not used)', False)
|
||||
minimum.isAdvanced = True
|
||||
self.addParameter(minimum)
|
||||
class_var = ParameterString(self.CLASS, 'Class - If multiple, separated by comma (set blank if not used)', 2, False, True)
|
||||
class_var = ParameterString(self.CLASS, 'Class(es)', 2, False, True)
|
||||
class_var.isAdvanced = True
|
||||
self.addParameter(class_var)
|
||||
advance_modifiers = ParameterString(self.ADVANCED_MODIFIERS, 'Additional modifiers', '', False, True)
|
||||
@ -112,7 +108,7 @@ class GridSurfaceCreate(FusionAlgorithm):
|
||||
commands.append('/class:' + str(class_var))
|
||||
advance_modifiers = str(self.getParameterValue(self.ADVANCED_MODIFIERS)).strip()
|
||||
if advance_modifiers:
|
||||
commands.append(s)
|
||||
commands.append(advance_modifiers)
|
||||
commands.append(self.getOutputValue(self.OUTPUT_DTM))
|
||||
commands.append(str(self.getParameterValue(self.CELLSIZE)))
|
||||
commands.append(self.UNITS[self.getParameterValue(self.XYUNITS)][0])
|
||||
@ -128,10 +124,3 @@ class GridSurfaceCreate(FusionAlgorithm):
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
FusionUtils.runFusion(commands, progress)
|
||||
ascii = self.getParameterValue(self.ASCII)
|
||||
if ascii == 1:
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'DTM2ASCII.exe')]
|
||||
commands.append(self.getOutputValue(self.OUTPUT_DTM))
|
||||
commands.append(self.getOutputValue(self.OUTPUT_ASCII))
|
||||
p = subprocess.Popen(commands, shell=True)
|
||||
p.wait()
|
78
python/plugins/processing/algs/lidar/fusion/PolyClipData.py
Normal file
78
python/plugins/processing/algs/lidar/fusion/PolyClipData.py
Normal file
@ -0,0 +1,78 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
***************************************************************************
|
||||
PolyClipData.py
|
||||
---------------------
|
||||
Date : May 2014
|
||||
Copyright : (C) 2014 by Niccolo' Marchi
|
||||
Email : sciurusurbanus at hotmail dot it
|
||||
***************************************************************************
|
||||
* *
|
||||
* 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__ = "Niccolo' Marchi"
|
||||
__date__ = 'May 2014'
|
||||
__copyright__ = "(C) 2014 by Niccolo' Marchi"
|
||||
|
||||
# This will get replaced with a git SHA1 when you do a git archive
|
||||
|
||||
__revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
from PyQt4 import QtGui
|
||||
from processing.parameters.ParameterFile import ParameterFile
|
||||
from processing.parameters.ParameterVector import ParameterVector
|
||||
from processing.parameters.ParameterBoolean import ParameterBoolean
|
||||
from processing.parameters.ParameterString import ParameterString
|
||||
from processing.outputs.OutputFile import OutputFile
|
||||
from FusionAlgorithm import FusionAlgorithm
|
||||
from FusionUtils import FusionUtils
|
||||
|
||||
|
||||
class PolyClipData(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT = 'OUTPUT'
|
||||
SHAPE = 'SHAPE'
|
||||
MASK = 'MASK'
|
||||
FIELD ='FIELD'
|
||||
VALUE = 'VALUE'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'Poly Clip Data'
|
||||
self.group = 'Points'
|
||||
self.addParameter(ParameterFile(self.INPUT, 'Input .las layer'))
|
||||
self.addParameter(ParameterFile(self.MASK, 'Mask layer'))
|
||||
self.addOutput(OutputFile(self.OUTPUT, 'Output clipped .las file', 'las'))
|
||||
self.addParameter(ParameterBoolean(self.SHAPE, 'Use Shape attribute ', False))
|
||||
## 'field' e 'value' box should appear or get activated if Shape attribute is switched ON
|
||||
self.addParameter(ParameterString(self.FIELD, 'Shape field index'))
|
||||
self.addParameter(ParameterString(self.VALUE, "Shape value"))
|
||||
self.addAdvancedModifiers()
|
||||
|
||||
|
||||
def processAlgorithm(self, progress):
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'PolyClipData.exe')]
|
||||
commands.append('/verbose')
|
||||
if self.getParameterValue(self.SHAPE):
|
||||
commands.append('/shape:' + str(self.getParameterValue(self.FIELD)) + ',' + str(self.getParameterValue(self.VALUE)))
|
||||
self.addAdvancedModifiersToCommand(commands)
|
||||
commands.append(self.getParameterValue(self.MASK))
|
||||
outFile = self.getOutputValue(self.OUTPUT)
|
||||
commands.append(outFile)
|
||||
files = self.getParameterValue(self.INPUT).split(';')
|
||||
if len(files) == 1:
|
||||
commands.append(self.getParameterValue(self.INPUT))
|
||||
else:
|
||||
FusionUtils.createFileList(files)
|
||||
commands.append(FusionUtils.tempFileListFilepath())
|
||||
|
||||
FusionUtils.runFusion(commands, progress)
|
@ -39,13 +39,11 @@ class TinSurfaceCreate(FusionAlgorithm):
|
||||
|
||||
INPUT = 'INPUT'
|
||||
OUTPUT_DTM = 'OUTPUT_DTM';
|
||||
OUTPUT_ASCII = 'OUTPUT_ASCII';
|
||||
CELLSIZE = 'CELLSIZE'
|
||||
XYUNITS = 'XYUNITS'
|
||||
ZUNITS = 'ZUNITS'
|
||||
UNITS = ['Meter', 'Feet']
|
||||
CLASS = 'CLASS'
|
||||
ASCII = 'ASCII'
|
||||
|
||||
def defineCharacteristics(self):
|
||||
self.name = 'Tin Surface Create'
|
||||
@ -55,9 +53,7 @@ class TinSurfaceCreate(FusionAlgorithm):
|
||||
self.addParameter(ParameterSelection(self.XYUNITS, 'XY Units', self.UNITS))
|
||||
self.addParameter(ParameterSelection(self.ZUNITS, 'Z Units', self.UNITS))
|
||||
self.addOutput(OutputFile(self.OUTPUT_DTM, 'DTM Output Surface', 'dtm'))
|
||||
self.addOutput(OutputFile(self.OUTPUT_ASCII, 'ASCII Output Surface', 'asc'))
|
||||
self.addParameter(ParameterBoolean(self.ASCII, 'ASCII Output?'))
|
||||
class_var = ParameterString(self.CLASS, 'Class(set blank if not used)', 2, False, True)
|
||||
class_var = ParameterString(self.CLASS, 'Class', 2, False, True)
|
||||
class_var.isAdvanced = True
|
||||
self.addParameter(class_var)
|
||||
|
||||
@ -82,10 +78,3 @@ class TinSurfaceCreate(FusionAlgorithm):
|
||||
else:
|
||||
commands.extend(files)
|
||||
FusionUtils.runFusion(commands, progress)
|
||||
ascii = self.getParameterValue(self.ASCII)
|
||||
if ascii == 1:
|
||||
commands = [os.path.join(FusionUtils.FusionPath(), 'DTM2ASCII.exe')]
|
||||
commands.append(self.getOutputValue(self.OUTPUT_DTM))
|
||||
commands.append(self.getOutputValue(self.OUTPUT_ASCII))
|
||||
p = subprocess.Popen(commands, shell=True)
|
||||
p.wait()
|
Loading…
x
Reference in New Issue
Block a user