-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@161 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
- Loading branch information
volayaf
committed
Apr 27, 2012
1 parent
ebf7d1e
commit 98c2bb0
Showing
17 changed files
with
288 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
from sextante.outputs.OutputTable import OutputTable | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.fusion.FusionUtils import FusionUtils | ||
from PyQt4 import QtGui | ||
from sextante.parameters.ParameterNumber import ParameterNumber | ||
from sextante.fusion.FusionAlgorithm import FusionAlgorithm | ||
|
||
class CanopyMaxima(FusionAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
THRESHOLD = "THRESHOLD" | ||
GROUND = "GROUND" | ||
|
||
|
||
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", 0, None, 10.0)) | ||
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") | ||
self.addAdvancedModifiersToCommand(commands) | ||
ground = self.getParameterValue(self.GROUND) | ||
if str(ground).strip() != "": | ||
commands.append("/ground:" + str(ground)) | ||
commands.append("/threshold:" + str(self.getParameterValue(self.THRESHOLD))) | ||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
from sextante.fusion.FusionUtils import FusionUtils | ||
from sextante.parameters.ParameterNumber import ParameterNumber | ||
from sextante.outputs.OutputRaster import OutputRaster | ||
from sextante.parameters.ParameterSelection import ParameterSelection | ||
import subprocess | ||
from sextante.fusion.FusionAlgorithm import FusionAlgorithm | ||
|
||
class CanopyModel(FusionAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
CELLSIZE = "CELLSIZE" | ||
GROUND = "GROUND" | ||
XYUNITS = "XYUNITS" | ||
ZUNITS = "ZUNITS" | ||
UNITS = ["Meter", "Feet"] | ||
|
||
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() | ||
|
||
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) | ||
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]) | ||
commands.append("0") | ||
commands.append("0") | ||
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) | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import os | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.fusion.FusionUtils import FusionUtils | ||
from PyQt4 import QtGui | ||
import subprocess | ||
from sextante.parameters.ParameterExtent import ParameterExtent | ||
from sextante.outputs.OutputFile import OutputFile | ||
from sextante.parameters.ParameterSelection import ParameterSelection | ||
from sextante.fusion.FusionAlgorithm import FusionAlgorithm | ||
|
||
class ClipData(FusionAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
EXTENT = "EXTENT" | ||
SHAPE = "SHAPE" | ||
|
||
|
||
def defineCharacteristics(self): | ||
self.name = "Clip Data" | ||
self.group = "Points" | ||
self.addParameter(ParameterFile(self.INPUT, "Input las layer")) | ||
self.addParameter(ParameterExtent(self.EXTENT, "Extent")) | ||
self.addParameter(ParameterSelection(self.SHAPE, "Shape", ["Rectangle","Circle"])) | ||
self.addOutput(OutputFile(self.OUTPUT, "Output clipped las file")) | ||
self.addAdvancedModifiers() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(FusionUtils.FusionPath(), "ClipData.exe")] | ||
commands.append("/verbose") | ||
self.addAdvancedModifiersToCommand(commands) | ||
commands.append("/shape:" + str(self.getParameterValue(self.SHAPE))) | ||
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) | ||
extent = str(self.getParameterValue(self.EXTENT)).split(",") | ||
commands.append(extent[0]) | ||
commands.append(extent[2]) | ||
commands.append(extent[1]) | ||
commands.append(extent[3]) | ||
FusionUtils.runFusion(commands, progress) | ||
commands = [os.path.join(FusionUtils.FusionPath(), "LDA2LAS.exe")] | ||
commands.append(outFile) | ||
commands.append(self.getOutputValue(self.OUTPUT)) | ||
p = subprocess.Popen(commands, shell=True) | ||
p.wait() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import os | ||
from sextante.parameters.ParameterFile import ParameterFile | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
from sextante.fusion.FusionUtils import FusionUtils | ||
from PyQt4 import QtGui | ||
from sextante.parameters.ParameterNumber import ParameterNumber | ||
from sextante.outputs.OutputRaster import OutputRaster | ||
from sextante.parameters.ParameterSelection import ParameterSelection | ||
import subprocess | ||
from sextante.fusion.FusionAlgorithm import FusionAlgorithm | ||
|
||
class Cover(FusionAlgorithm): | ||
|
||
INPUT = "INPUT" | ||
OUTPUT = "OUTPUT" | ||
CELLSIZE = "CELLSIZE" | ||
HEIGHTBREAK = "HEIGHTREAK" | ||
GROUND = "GROUND" | ||
XYUNITS = "XYUNITS" | ||
ZUNITS = "ZUNITS" | ||
UNITS = ["Meter", "Feet"] | ||
|
||
def defineCharacteristics(self): | ||
self.name = "Cover" | ||
self.group = "Points" | ||
self.addParameter(ParameterFile(self.INPUT, "Input las layer")) | ||
self.addParameter(ParameterFile(self.GROUND, "Input ground DTM layer")) | ||
self.addParameter(ParameterNumber(self.CELLSIZE, "Cellsize", 0, None, 10.0)) | ||
self.addParameter(ParameterNumber(self.HEIGHTBREAK, "Heightbreak", 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, "Cover")) | ||
self.addAdvancedModifiers() | ||
|
||
def processAlgorithm(self, progress): | ||
commands = [os.path.join(FusionUtils.FusionPath(), "Cover.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) | ||
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]) | ||
commands.append("0") | ||
commands.append("0") | ||
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) | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from sextante.core.GeoAlgorithm import GeoAlgorithm | ||
import os | ||
from PyQt4 import QtGui | ||
from sextante.fusion.FusionUtils import FusionUtils | ||
from sextante.parameters.ParameterString import ParameterString | ||
|
||
class FusionAlgorithm(GeoAlgorithm): | ||
|
||
ADVANCED_MODIFIERS = "ADVANCED_MODIFIERS" | ||
|
||
def getIcon(self): | ||
filepath = os.path.dirname(__file__) + "/../images/tool.png" | ||
return QtGui.QIcon(filepath) | ||
|
||
def checkBeforeOpeningParametersDialog(self): | ||
path = FusionUtils.FusionPath() | ||
if path == "": | ||
return "Fusion folder is not configured.\nPlease configure it before running Fusion algorithms." | ||
|
||
def addAdvancedModifiers(self): | ||
param = ParameterString(self.ADVANCED_MODIFIERS, "Additional modifiers", "") | ||
param.isAdvanced = True | ||
self.addParameter(param) | ||
|
||
def addAdvancedModifiersToCommand(self, commands): | ||
s = str(self.getParameterValue(self.ADVANCED_MODIFIERS)).strip() | ||
if s != "": | ||
commands.append(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.