Skip to content
Permalink
Browse files
[processing] Update of fusion lidar algorithms (By Agresta S.Coop)
  • Loading branch information
volaya committed Jun 30, 2014
1 parent 6bef78f commit 9204ca02b66db45a8a102566c4164e78b12dbb85
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

"""
***************************************************************************
@@ -11,6 +11,10 @@
Date : April 2014
Copyright : (C) 2014 by Martin Isenburg
Email : martin near rapidlasso point com
---------------------
Date : June 2014
Copyright : (C) 2014 by Agresta S. Coop
Email : iescamochero at agresta dot org
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -88,11 +92,14 @@
from fusion.OpenViewerAction import OpenViewerAction
from fusion.CanopyMaxima import CanopyMaxima
from fusion.CanopyModel import CanopyModel
from fusion.Catalog import Catalog
from fusion.ClipData import ClipData
from fusion.CloudMetrics import CloudMetrics
from fusion.Cover import Cover
from fusion.GridMetrics import GridMetrics
from fusion.GridSurfaceCreate import GridSurfaceCreate
from fusion.TinSurfaceCreate import TinSurfaceCreate
from fusion.Csv2Grid import Csv2Grid
from fusion.GroundFilter import GroundFilter
from fusion.MergeData import MergeData
from fusion.FilterData import FilterData
@@ -146,7 +153,8 @@ def __init__(self):

if isWindows():
lastoolsPipe = [
flightlinesToDTMandDSM(), flightlinesToCHM(), flightlinesToSingleCHMpitFree(), hugeFileClassify(), hugeFileGroundClassify(), hugeFileNormalize()
flightlinesToDTMandDSM(), flightlinesToCHM(), flightlinesToSingleCHMpitFree(), hugeFileClassify(),
hugeFileGroundClassify(), hugeFileNormalize()
]
else:
lastoolsPipe = [
@@ -160,9 +168,9 @@ def __init__(self):
if isWindows():
self.actions.append(OpenViewerAction())
fusiontools = [
CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(),
Cover(), FilterData(), GridMetrics(), GroundFilter(),
GridSurfaceCreate(), MergeData()
Catalog(), CloudMetrics(), CanopyMaxima(), CanopyModel(), ClipData(),
Csv2Grid(), Cover(), FilterData(), GridMetrics(), GroundFilter(),
GridSurfaceCreate(), MergeData(), TinSurfaceCreate()
]
for alg in fusiontools:
alg.group = 'Fusion'
@@ -26,9 +26,6 @@
__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.outputs.OutputTable import OutputTable
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

"""
***************************************************************************
@@ -7,6 +7,10 @@
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
---------------------
Date : June 2014
Copyright : (C) 2014 by Agresta S. Coop.
Email : iescamochero at agresta dot org
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,55 +24,89 @@
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'

# 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.ParameterNumber import ParameterNumber
from processing.parameters.ParameterSelection import ParameterSelection
from processing.outputs.OutputRaster import OutputRaster
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 CanopyModel(FusionAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
CELLSIZE = 'CELLSIZE'
GROUND = 'GROUND'
OUTPUT_DTM = 'OUTPUT_DTM'
OUTPUT_ASCII = 'OUTPUT_ASCII'
CELLSIZE = 'CELLSIZE'
XYUNITS = 'XYUNITS'
ZUNITS = 'ZUNITS'
UNITS = ['Meter', 'Feet']
GROUND = 'GROUND'
MEDIAN = 'MEDIAN'
SMOOTH = 'SMOOTH'
SLOPE = 'SLOPE'
CLASS = 'CLASS'
ASCII = 'ASCII'
ADVANCED_MODIFIERS = 'ADVANCED_MODIFIERS'

def defineCharacteristics(self):
self.name = 'Canopy Model'
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.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.addOutput(OutputRaster(self.OUTPUT, 'Canopy model'))
self.addAdvancedModifiers()
self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
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'))
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.isAdvanced = True
self.addParameter(median)
smooth = ParameterString(self.SMOOTH, 'Smooth (set blank if not used)', '', False, True)
smooth.isAdvanced = True
self.addParameter(smooth)
slope = ParameterString(self.SLOPE, 'Slope (set blank if not used)', '', False, True)
slope.isAdvanced = True
self.addParameter(slope)
class_var = ParameterString(self.CLASS, 'Class (set blank if not used)', '', False, True)
class_var.isAdvanced = True
self.addParameter(class_var)
advance_modifiers = ParameterString(self.ADVANCED_MODIFIERS, 'Additional modifiers', '', False, True)
advance_modifiers.isAdvanced = True
self.addParameter(advance_modifiers)

def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), 'CanopyModel.exe')]
commands.append('/verbose')
self.addAdvancedModifiersToCommand(commands)
ground = self.getParameterValue(self.GROUND)
if str(ground).strip() != '':
commands.append('/ground:' + str(ground))
outFile = self.getOutputValue(self.OUTPUT) + '.dtm'
commands.append(outFile)
median = self.getParameterValue(self.MEDIAN)
if str(median).strip() != '':
commands.append('/median:' + str(median))
smooth = self.getParameterValue(self.SMOOTH)
if str(smooth).strip() != '':
commands.append('/smooth:' + str(smooth))
slope = self.getParameterValue(self.SLOPE)
if str(slope).strip() != '':
commands.append('/slope:' + str(slope))
class_var = self.getParameterValue(self.CLASS)
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)
commands.append(self.getOutputValue(self.OUTPUT_DTM))
commands.append(str(self.getParameterValue(self.CELLSIZE)))
commands.append(self.UNITS[self.getParameterValue(self.XYUNITS)][0])
commands.append(self.UNITS[self.getParameterValue(self.ZUNITS)][0])
@@ -83,8 +121,10 @@ def processAlgorithm(self, progress):
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())
FusionUtils.runFusion(commands, progress)
commands = [os.path.join(FusionUtils.FusionPath(), 'DTM2TIF.exe')]
commands.append(outFile)
commands.append(self.getOutputValue(self.OUTPUT))
p = subprocess.Popen(commands, shell=True)
p.wait()
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()
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
Catalog.py
---------------------
Date : June 2014
Copyright : (C) 2014 by Agresta S. Coop
Email : iescamochero at agresta dot org
***************************************************************************
* *
* 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__ = 'Agresta S. Coop - www.agresta.org'
__date__ = 'June 2014'
__copyright__ = '(C) 2014, Agresta S. Coop'
# 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.ParameterString import ParameterString
from processing.outputs.OutputFile import OutputFile
from FusionUtils import FusionUtils
from FusionAlgorithm import FusionAlgorithm


class Catalog(FusionAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
DENSITY = 'DENSITY'
FIRSTDENSITY = 'FIRSTDENSITY'
INTENSITY = 'INTENSITY'
ADVANCED_MODIFIERS = 'ADVANCED_MODIFIERS'

def defineCharacteristics(self):
self.name = 'Catalog'
self.group = 'Points'
self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
self.addOutput(OutputFile(self.OUTPUT, 'Output files'))
density = ParameterString(self.DENSITY, 'Density - area, min, max (set blank if not used)', '', False, True)
density.isAdvanced = True
self.addParameter(density)
firest_density = ParameterString(self.FIRSTDENSITY, 'First Density - area, min, max (set blank if not used)', '', False, True)
firest_density.isAdvanced = True
self.addParameter(firest_density)
intensity = ParameterString(self.INTENSITY, 'Intensity - area, min, max (set blank if not used)', '', False, True)
intensity.isAdvanced = True
self.addParameter(intensity)
advanced_modifiers = ParameterString(self.ADVANCED_MODIFIERS, 'Additional modifiers', '', False, True)
advanced_modifiers.isAdvanced = True
self.addParameter(advanced_modifiers)


def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), 'Catalog.exe')]
commands.append('/verbose')
intensity = self.getParameterValue(self.INTENSITY)
if str(intensity).strip():
commands.append('/intensity:' + str(intensity))
density = self.getParameterValue(self.DENSITY)
if str(density).strip():
commands.append('/density:' + str(density))
firstdensity = self.getParameterValue(self.FIRSTDENSITY)
if str(firstdensity).strip():
commands.append('/firstdensity:' + str(firstdensity))
advanced_modifiers = str(self.getParameterValue(self.ADVANCED_MODIFIERS)).strip()
if advanced_modifiers:
commands.append(advanced_modifiers)
files = self.getParameterValue(self.INPUT).split(';')
if len(files) == 1:
commands.append(self.getParameterValue(self.INPUT))
else:
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())
commands.append(self.getOutputValue(self.OUTPUT))
FusionUtils.runFusion(commands, progress)
@@ -27,7 +27,6 @@

import os
import subprocess
from PyQt4 import QtGui
from processing.parameters.ParameterFile import ParameterFile
from processing.parameters.ParameterExtent import ParameterExtent
from processing.parameters.ParameterSelection import ParameterSelection
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-

"""
***************************************************************************
@@ -7,6 +7,10 @@
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
---------------------
Date : June 2014
Copyright : (C) 2014 by Agresta S. Coop.
Email : iescamochero at agresta dot org
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,41 +24,65 @@
__author__ = 'Victor Olaya'
__date__ = 'August 2012'
__copyright__ = '(C) 2012, Victor Olaya'

# 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.OutputTable import OutputTable
from processing.outputs.OutputFile import OutputFile
from FusionUtils import FusionUtils
from FusionAlgorithm import FusionAlgorithm
from processing.parameters.ParameterString import ParameterString
from processing.parameters.ParameterBoolean import ParameterBoolean


class CloudMetrics(FusionAlgorithm):

INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
ABOVE = 'ABOVE'
FIRSTIMPULSE = 'FIRSTIMPULSE'
FIRSTRETURN = 'FIRSTRETURN'
HTMIN = 'HTMIN'

def defineCharacteristics(self):
self.name = 'Cloud Metrics'
self.group = 'Points'
self.addParameter(ParameterFile(self.INPUT, 'Input las layer'))
self.addOutput(OutputTable(self.OUTPUT,
'Output file with tabular metric information'))
self.addAdvancedModifiers()
self.addOutput(OutputFile(self.OUTPUT, 'Output file with tabular metric information', 'dtm'))
above = ParameterString(self.ABOVE, 'Above', '', False)
above.isAdvanced = True
self.addParameter(above)
firstImpulse = ParameterBoolean(self.FIRSTIMPULSE, 'First Impulse', False)
firstImpulse.isAdvanced = True
self.addParameter(firstImpulse)
firstReturn = ParameterBoolean(self.FIRSTRETURN, 'First Return', False)
firstReturn.isAdvanced = True
self.addParameter(firstReturn)
htmin = ParameterString(self.HTMIN, 'Htmin', '', False, True)
htmin.isAdvanced = True
self.addParameter(htmin)

def processAlgorithm(self, progress):
commands = [os.path.join(FusionUtils.FusionPath(), 'CloudMetrics.exe')]
commands.append('/verbose')
self.addAdvancedModifiersToCommand(commands)
above = self.getParameterValue(self.ABOVE)
if str(above).strip() != '':
commands.append('/above:' + str(above))
firstImpulse = self.getParameterValue(self.FIRSTIMPULSE)
if firstImpulse:
commands.append('/firstinpulse:' + firstImpulse)
firstReturn = self.getParameterValue(self.FIRSTRETURN)
if firstReturn:
commands.append('/firstreturn:' + first_return)
htmin = self.getParameterValue(self.HTMIN)
if str(htmin).strip() != '':
commands.append('/minht:' + str(htmin))
files = self.getParameterValue(self.INPUT).split(';')
if len(files) == 1:
commands.append(self.getParameterValue(self.INPUT))
else:
FusionUtils.createFileList(files)
commands.append(FusionUtils.tempFileListFilepath())
commands.append(self.getOutputValue(self.OUTPUT))

FusionUtils.runFusion(commands, progress)

0 comments on commit 9204ca0

Please sign in to comment.