Skip to content
Permalink
Browse files
more grass-sextante improvements (mainly fine tuning some algorithms)
  • Loading branch information
volaya committed Dec 13, 2012
1 parent 6637268 commit f2fc33bb3a2389580104e060a668bec8019ab1f3
@@ -0,0 +1,11 @@
diff --git a/grass/description/r.neighbors.txt b/grass/description/r.neighbors.txt
index 076ad54..5d7017e 100644
--- a/grass/description/r.neighbors.txt
+++ b/grass/description/r.neighbors.txt
@@ -5,4 +5,6 @@
ParameterSelection|method|Neighborhood operation|average;median;mode;minimum;maximum;stddev;sum;variance;diversity;interspersion
ParameterNumber|size|Neighborhood size|1.0|None|3
ParameterBoolean|-c|Use circular neighborhood|False
+*ParameterBoolean|-a|Do not align output with the input|False
+*ParameterFile|weight|File containing weights|False
OutputRaster|output|Name for output raster map
@@ -269,6 +269,8 @@ def processAlgorithm(self, progress):
elif isinstance(param, ParameterSelection):
idx = int(param.value)
command+=(" " + param.name + "=" + str(param.options[idx]));
elif isinstance(param, ParameterSelection):
command+=(" " + param.name + "=" + str(param.value));
else:
command+=(" " + param.name + "=" + str(param.value));

@@ -331,7 +333,7 @@ def processAlgorithm(self, progress):
def postProcessResults(self):
name = self.commandLineName().replace('.','_')[len('grass:'):]
try:
module = importlib.import_module('sextante.grass.postproc.' + name)
module = importlib.import_module('sextante.grass.ext.' + name)
except ImportError:
return
if hasattr(module, 'postProcessResults'):
@@ -396,4 +398,14 @@ def getTempFilename(self):

def commandLineName(self):
return "grass:" + self.name[:self.name.find(" ")]

def checkParameterValuesBeforeExecuting(self):
name = self.commandLineName().replace('.','_')[len('grass:'):]
try:
module = importlib.import_module('sextante.grass.ext.' + name)
except ImportError:
return
if hasattr(module, 'checkParameterValuesBeforeExecuting'):
func = getattr(module,'checkParameterValuesBeforeExecuting')
return func(self)

@@ -1,6 +1,6 @@
r.cross
r.cross - Creates a cross product of the category values from multiple raster map layers.
Raster (r.*)
ParameterMultipleInput|input|Names of 2-30 input raster maps|3.0|False
ParameterMultipleInput|input|Input raster layers|3.0|False
ParameterBoolean|-z|Non-zero data only|False
OutputRaster|output|Name for output raster map
OutputRaster|output|Output layer
@@ -5,4 +5,6 @@ ParameterRaster|input|Name of input raster map|False
ParameterSelection|method|Neighborhood operation|average;median;mode;minimum;maximum;stddev;sum;variance;diversity;interspersion
ParameterNumber|size|Neighborhood size|1.0|None|3
ParameterBoolean|-c|Use circular neighborhood|False
*ParameterBoolean|-a|Do not align output with the input|False
*ParameterFile|weight|File containing weights|False
OutputRaster|output|Name for output raster map
@@ -3,5 +3,5 @@ v.to.rast.attribute - Converts (rasterize) a vector layer into a raster layer.
Vector (v.*)
ParameterVector|input|Input vector layer|-1|False
ParameterSelection|use|Source of raster values|attr
ParameterTableField|column|Name of column for 'attr' parameter (data type must be numeric)|input
ParameterTableField|column|Name of column for 'attr' parameter (data type must be numeric)|input|0
OutputRaster|output|Rasterized layer
File renamed without changes.
File renamed without changes.
@@ -27,27 +27,32 @@

class ParameterFile(Parameter):

def __init__(self, name="", description="", isFolder = False):
def __init__(self, name="", description="", isFolder = False, optional = True):
Parameter.__init__(self, name, description)
self.value = None
self.isFolder = isFolder
self.optional = optional

def getValueAsCommandLineParameter(self):
return "\"" + str(self.value) + "\""

def serialize(self):
return self.__module__.split(".")[-1] + "|" + self.name + "|" + self.description +\
"|" + str(self.isFolder)
"|" + str(self.isFolder) + "|" + str(self.optional)

def setValue(self, obj):
self.value = str(obj)
if self.value.strip() == "":
return False
if not self.optional:
return False
return True

def deserialize(self, s):
tokens = s.split("|")
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))
if len(tokens) == 4:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True), tokens[3] == str(True))
else:
return ParameterFile(tokens[0], tokens[1], tokens[2] == str(True))

def getAsScriptCode(self):
if self.isFolder:

0 comments on commit f2fc33b

Please sign in to comment.