Skip to content
Permalink
Browse files

otb: region of interest.

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@249 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com
cpolymeris@gmail.com committed Jun 16, 2012
1 parent 1c4a756 commit 3d9f712b2bb209eee45e7a686bd23e709a3e8f7a
Showing with 29 additions and 4 deletions.
  1. +29 −4 src/sextante/otb/OTBAlgorithm.py
@@ -12,14 +12,19 @@
from sextante.parameters.ParameterSelection import ParameterSelection
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from sextante.core.SextanteLog import SextanteLog
#~ from sextante.core.Sextante import Sextante
from sextante.parameters.ParameterFactory import ParameterFactory
from sextante.outputs.OutputFactory import OutputFactory
from sextante.otb.OTBUtils import OTBUtils
from sextante.parameters.ParameterExtent import ParameterExtent

class OTBAlgorithm(GeoAlgorithm):

REGION_OF_INTEREST = "ROI"

def __init__(self, descriptionfile):
GeoAlgorithm.__init__(self)
self.roiFile = None
self.descriptionFile = descriptionfile
self.defineCharacteristicsFromFile()
self.numExportedLayers = 0
@@ -60,8 +65,11 @@ def defineCharacteristicsFromFile(self):
param.default = OTBUtils.otbSRTMPath()
if param.name == "-elev.dem.geoid":
param.default = OTBUtils.otbGeoidPath()

self.addParameter(param)
elif line.startswith("Extent"):
self.extentParamNames = line[6:].strip().split(" ")
self.addParameter(ParameterExtent(self.REGION_OF_INTEREST, "Region of interest", "0,1,0,1"))
self.roiFile = SextanteUtils.getTempFilename()
else:
self.addOutput(OutputFactory.getFromString(line))
line = lines.readline().strip("\n").strip()
@@ -83,9 +91,16 @@ def processAlgorithm(self, progress):
for param in self.parameters:
if param.value == None or param.value == "":
continue
if isinstance(param, (ParameterRaster, ParameterVector)):
if isinstance(param, ParameterVector):
commands.append(param.name)
commands.append(param.value)
if isinstance(param, ParameterRaster):
commands.append(param.name)
if self.roiFile:
commands.append(self.roiFile)
self.roiInput = param.name
else:
commands.append(param.value)
elif isinstance(param, ParameterMultipleInput):
commands.append(param.name)
commands.append(str(param.value.replace(";"," ")))
@@ -97,14 +112,24 @@ def processAlgorithm(self, progress):
if param.value:
commands.append(param.name)
commands.append(str(param.value).lower())
elif isinstance(param, ParameterExtent):
self.roiValues = param.value.split(",")
else:
commands.append(param.name)
commands.append(str(param.value))

for out in self.outputs:
commands.append(out.name)
commands.append(out.value);

commands.append(out.value)

if self.roiFile:
args = {"in": self.roiInput,
"out": self.roiFile,
"startx": self.roiValues[0],
"starty": self.roiValues[1],
"sizex": self.roiValues[2],
"sizey": self.roiValues[3]}
Sextante.runalg("ExtractROI", *args)

loglines = []
loglines.append("OTB execution command")

0 comments on commit 3d9f712

Please sign in to comment.
You can’t perform that action at this time.