Showing with 208 additions and 156 deletions.
  1. +2 −1 python/plugins/sextante/algs/FieldsCalculator.py
  2. +0 −1 python/plugins/sextante/algs/ftools/Centroids.py
  3. +0 −1 python/plugins/sextante/algs/ftools/FixedDistanceBuffer.py
  4. +1 −2 python/plugins/sextante/core/AlgorithmProvider.py
  5. +37 −4 python/plugins/sextante/core/GeoAlgorithm.py
  6. +1 −2 python/plugins/sextante/core/QGisLayers.py
  7. +5 −3 python/plugins/sextante/core/Sextante.py
  8. +57 −0 python/plugins/sextante/core/SextanteRasterWriter.py
  9. +6 −6 python/plugins/sextante/core/SextanteTableWriter.py
  10. +1 −1 python/plugins/sextante/gdal/warp.py
  11. +5 −3 python/plugins/sextante/grass/GrassAlgorithm.py
  12. +1 −1 python/plugins/sextante/grass/description/r.los.txt
  13. +1 −1 python/plugins/sextante/grass/description/r.mapcalculator.txt
  14. +1 −1 python/plugins/sextante/grass/description/r.plane.txt
  15. +6 −0 python/plugins/sextante/grass/description/r.reclass.area.greater.txt
  16. +6 −0 python/plugins/sextante/grass/description/r.reclass.area.lesser.txt
  17. +0 −7 python/plugins/sextante/grass/description/r.reclass.area.txt
  18. +2 −2 python/plugins/sextante/grass/description/r.reclass.txt
  19. +3 −5 python/plugins/sextante/grass/description/r.recode.txt
  20. +2 −2 python/plugins/sextante/grass/description/r.regression.line.txt
  21. +5 −7 python/plugins/sextante/grass/description/r.report.txt
  22. +3 −3 python/plugins/sextante/grass/description/r.resamp.interp.txt
  23. +3 −4 python/plugins/sextante/grass/description/r.resamp.rst.txt
  24. +3 −3 python/plugins/sextante/grass/description/r.resamp.stats.txt
  25. +2 −2 python/plugins/sextante/grass/description/r.resample.txt
  26. +4 −4 python/plugins/sextante/grass/description/r.rescale.eq.txt
  27. +5 −5 python/plugins/sextante/grass/description/r.rescale.txt
  28. +0 −16 python/plugins/sextante/grass/description/r.ros.txt
  29. +4 −6 python/plugins/sextante/grass/description/r.series.txt
  30. +3 −3 python/plugins/sextante/grass/description/r.shaded.relief.txt
  31. +12 −13 python/plugins/sextante/grass/description/r.slope.aspect.txt
  32. +0 −10 python/plugins/sextante/grass/description/r.slope.txt
  33. +0 −21 python/plugins/sextante/grass/description/r.spread.txt
  34. +1 −2 python/plugins/sextante/grass/description/r.spreadpath.txt
  35. +4 −4 python/plugins/sextante/grass/description/r.statistics.txt
  36. +1 −1 python/plugins/sextante/gui/SextanteToolbox.py
  37. +1 −2 python/plugins/sextante/modeler/ModelerAlgorithmProvider.py
  38. +0 −1 python/plugins/sextante/modeler/ModelerParametersDialog.py
  39. +15 −1 python/plugins/sextante/outputs/OutputRaster.py
  40. +3 −2 python/plugins/sextante/outputs/OutputVector.py
  41. +2 −3 python/plugins/sextante/saga/description/Merging.txt
3 changes: 2 additions & 1 deletion python/plugins/sextante/algs/FieldsCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def processAlgorithm(self, progress):
try:
result = eval(expression)
except Exception:
raise GeoAlgorithmExecutionException("Problem evaluation formula: Wrong field values or formula")
result = None
#raise GeoAlgorithmExecutionException("Problem evaluation formula: Wrong field values or formula")
nElement += 1
inGeom = inFeat.geometry()
outFeat.setGeometry(inGeom)
Expand Down
1 change: 0 additions & 1 deletion python/plugins/sextante/algs/ftools/Centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from PyQt4 import QtGui
from PyQt4.QtCore import *

from qgis.core import *
Expand Down
1 change: 0 additions & 1 deletion python/plugins/sextante/algs/ftools/FixedDistanceBuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):
layer = QGisLayers.getObjectFromUri(self.getParameterValue(self.INPUT))
useSelection = self.getParameterValue(self.USE_SELECTED)
distance = self.getParameterValue(self.DISTANCE)
dissolve = self.getParameterValue(self.DISSOLVE)
segments = int(self.getParameterValue(self.SEGMENTS))
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/sextante/core/AlgorithmProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def getSupportedOutputVectorLayerExtensions(self):
extension = extension[:extension.find(" ")]
if extension.lower() != "shp":
extensions.append(extension)
return extensions
#return ["shp"]
return extensions

def getSupportedOutputTableExtensions(self):
return ["csv"]
Expand Down
41 changes: 37 additions & 4 deletions python/plugins/sextante/core/GeoAlgorithm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
GeoAlgorithmExecutionException.py
---------------------
Date : August 2012
Copyright : (C) 2012 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* 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__ = '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.path
import traceback
import copy
from sextante.outputs.Output import Output
from sextante.parameters.Parameter import Parameter
from sextante.core.QGisLayers import QGisLayers
Expand All @@ -6,18 +34,14 @@
from PyQt4 import QtGui
from PyQt4.QtCore import *
from qgis.core import *
import os.path
from sextante.core.SextanteUtils import SextanteUtils
from sextante.parameters.ParameterMultipleInput import ParameterMultipleInput
from sextante.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
import traceback
from sextante.core.SextanteLog import SextanteLog
from sextante.outputs.OutputVector import OutputVector
from sextante.outputs.OutputRaster import OutputRaster
from sextante.outputs.OutputTable import OutputTable
from sextante.outputs.OutputHTML import OutputHTML
import copy
from sextante.core.SextanteVectorWriter import SextanteVectorWriter
from sextante.core.SextanteConfig import SextanteConfig
from sextante.gdal.GdalUtils import GdalUtils

Expand Down Expand Up @@ -177,13 +201,22 @@ def convertUnsupportedFormats(self, progress):
for feature in features:
writer.addFeature(feature)
elif isinstance(out, OutputRaster):
out.close()
if out.compatible is not None:
layer = QGisLayers.getObjectFromUri(out.compatible)
provider = layer.dataProvider()
writer = QgsRasterFileWriter(out.value)
format = self.getFormatShortNameFromFilename(out.value)
writer.setOutputFormat(format);
writer.writeRaster(layer.pipe(), layer.width(), layer.height(), layer.extent(), layer.crs())
elif isinstance(out, OutputTable):
if out.compatible is not None:
layer = QGisLayers.getObjectFromUri(out.compatible)
provider = layer.dataProvider()
writer = out.getTableWriter(provider.fields())
features = QGisLayers.features(layer)
for feature in features:
writer.addRecord(feature)
progress.setPercentage(100 * i / float(len(self.outputs)))

def getFormatShortNameFromFilename(self, filename):
Expand Down
3 changes: 1 addition & 2 deletions python/plugins/sextante/core/QGisLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from qgis.core import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import QtGui
from os import path
from sextante.core.SextanteConfig import SextanteConfig

Expand Down Expand Up @@ -61,7 +60,7 @@ def getSupportedOutputRasterLayerExtensions():

@staticmethod
def getSupportedOutputTableExtensions():
exts = ["dbf, csv"]
exts = ["csv"]
return exts

@staticmethod
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/sextante/core/Sextante.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ class Sextante:
modeler = ModelerAlgorithmProvider()

@staticmethod
def addProvider(provider):
def addProvider(provider, updateList = False):
'''use this method to add algorithms from external providers'''
'''Adding a new provider automatically initializes it, so there is no need to do it in advance'''
#Note: this might slow down the initialization process if there are many new providers added.
#Should think of a different solution
provider.initializeSettings()
Sextante.providers.append(provider)
SextanteConfig.loadSettings()
Sextante.updateAlgsList()
if updateList:
Sextante.updateAlgsList()

@staticmethod
def removeProvider(provider):
Expand Down Expand Up @@ -141,13 +142,14 @@ def updateAlgsList():
Sextante.fireAlgsListHasChanged()

@staticmethod
def loadFromProviders():
def loadFromProviders():
Sextante.loadAlgorithms()
Sextante.loadActions()
Sextante.loadContextMenuActions()

@staticmethod
def updateProviders():

for provider in Sextante.providers:
provider.loadAlgorithms()

Expand Down
57 changes: 57 additions & 0 deletions python/plugins/sextante/core/SextanteRasterWriter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-

"""
***************************************************************************
SextanteRasterWriter.py
---------------------
Date : January 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* 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__ = 'Victor Olaya'
__date__ = 'September 2012'
__copyright__ = '(C) 2012, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

from qgis.core import *
import numpy
from PyQt4.QtCore import *

class SextanteRasterWriter:

NODATA = -99999.0

def __init__(self, fileName, minx, miny, maxx, maxy, cellsize, nbands, crs):
self.fileName = fileName
self.nx = (maxx - minx) / float(cellsize)
self.ny = (maxy - miny) / float(cellsize)
self.matrix = numpy.empty(shape=(self.nx, self.ny, nbands))
self.matrix[:] = self.NODATA
self.cellsize = cellsize
self.crs = crs

def setValue(self, value, x, y, band = 0):
try:
self.matrix[x, y, band] = value
except IndexError:
pass

def getValue(self, x, y, band = 0):
try:
return matrix[x, y, band]
except IndexError:
return self.NODATA

def close(self):
#todo
pass
12 changes: 6 additions & 6 deletions python/plugins/sextante/core/SextanteTableWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ def __init__(self, fileName, encoding, fields):
settings = QSettings()
encoding = settings.value("/SextanteQGIS/encoding", "System").toString()

if fileName.endswith("csv"):
if not fileName.endswith("csv"):
fileName += ".csv"
file = open(fileName, "w")
file.write(";".join(field.name() for field in fields))
file.write("\n")
file.close()
file = open(fileName, "w")
file.write(";".join(field.name() for field in fields))
file.write("\n")
file.close()

def addFeature(self, values):
def addRecord(self, values):
file = open(self.fileName, "a")
file.write(";".join([value.toString() for value in values]))
file.write("\n")
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/gdal/warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def defineCharacteristics(self):

def processAlgorithm(self, progress):
srs = self.getParameterValue(warp.DEST_SRS)
self.crs = QgsCoordinateReferenceSystem(int(srs))
self.crs = QgsCoordinateReferenceSystem(srs)
commands = ["gdalwarp"]
commands.append("-s_srs")
commands.append(str(self.getParameterValue(warp.SOURCE_SRS)))
Expand Down
8 changes: 5 additions & 3 deletions python/plugins/sextante/grass/GrassAlgorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,17 @@ def defineCharacteristicsFromFile(self):
line = lines.readline().strip("\n").strip()
self.group = line
hasRasterOutput = False
hasVectorOutput = False
while line != "":
try:
line = line.strip("\n").strip()
if line.startswith("Parameter"):
parameter = ParameterFactory.getFromString(line);
self.addParameter(parameter)
if isinstance(parameter, ParameterVector):
hasVectorOutput = True
hasVectorOutput = True
if isinstance(parameter, ParameterMultipleInput) and parameter.datatype < 3:
hasVectorOutput = True
hasVectorOutput = True
elif line.startswith("*Parameter"):
param = ParameterFactory.getFromString(line[1:])
param.isAdvanced = True
Expand All @@ -151,10 +152,11 @@ def defineCharacteristicsFromFile(self):
param = ParameterNumber(self.GRASS_SNAP_TOLERANCE_PARAMETER, "v.in.ogr snap tolerance (-1 = no snap)", -1, None, -1.0)
param.isAdvanced = True
self.addParameter(param)
ParameterNumber(self.GRASS_MIN_AREA_PARAMETER, "v.in.ogr min area", 0, None, 0.0001)
param = ParameterNumber(self.GRASS_MIN_AREA_PARAMETER, "v.in.ogr min area", 0, None, 0.0001)
param.isAdvanced = True
self.addParameter(param)


def getDefaultCellsize(self):
cellsize = 0
for param in self.parameters:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/r.los.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ ParameterRaster|patt_map|Binary (1/0) raster layer to use as a mask|True
ParameterString|obs_elev|Viewing position height above the ground|1.75
ParameterString|max_dist|Maximum distance from the viewing point (meters)|10000
ParameterBoolean|-c|Consider earth curvature (current ellipsoid)|False
OutputRaster|output|Output raster layer
OutputRaster|output|Output raster layer
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ParameterRaster|dmap|Raster layer D|True
ParameterRaster|emap|Raster layer E|True
ParameterRaster|fmap|Raster layer F|True
ParameterString|formula|Formula| A*C+B
OutputRaster|outfile|Output raster layer
OutputRaster|outfile|Output raster layer
2 changes: 1 addition & 1 deletion python/plugins/sextante/grass/description/r.plane.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
r.plane
r.plane - Creates raster plane map given dip (inclination), aspect (azimuth) and one point.
r.plane - Creates raster plane layer given dip (inclination), aspect (azimuth) and one point.
Raster (r.*)
ParameterNumber|dip|Dip of plane. Value must be between -90 and 90 degrees|None|None|0.0
ParameterNumber|azimuth|Azimuth of the plane. Value must be between 0 and 360 degrees|None|None|0.0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
r.reclass.area
r.reclass.area.greater - Reclassifies a raster layer, selecting areas larger than a user specified size
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterNumber|greater|Area threshold [hectares]|0|None|1
OutputRaster|output|Output raster layer
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
r.reclass.area
r.reclass.area.lesser - Reclassifies a raster layer, selecting areas lower than a user specified size
Raster (r.*)
ParameterRaster|input|Input raster layer|False
ParameterNumber|lesser|Area threshold [hectares]|0|None|1
OutputRaster|output|Output raster layer
7 changes: 0 additions & 7 deletions python/plugins/sextante/grass/description/r.reclass.area.txt

This file was deleted.

4 changes: 2 additions & 2 deletions python/plugins/sextante/grass/description/r.reclass.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.reclass
r.reclass - Creates a new map layer whose category values are based upon a reclassification of the categories in an existing raster map layer.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input raster layer|False
ParameterFile|rules|File containing reclass rules|False
OutputRaster|output|Name for output raster map
OutputRaster|output|Output raster layer
8 changes: 3 additions & 5 deletions python/plugins/sextante/grass/description/r.recode.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
r.recode
r.recode - Recodes categorical raster maps.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input layer|False
ParameterFile|rules|File containing recode rules|False
ParameterString|title|Title for output raster map|
ParameterBoolean|-a|Align the current region to the input raster map|False
ParameterBoolean|-d|Force output to 'double' raster map type (DCELL)|False
OutputRaster|output|Name for output raster map
*ParameterBoolean|-d|Force output to 'double' raster map type (DCELL)|False
OutputRaster|output|Output raster layer
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
r.regression.line
r.regression.line - Calculates linear regression from two raster layers : y = a + b*x.
Raster (r.*)
ParameterRaster|map1|Map for x coefficient|False
ParameterRaster|map2|Map for y coefficient|False
ParameterRaster|map1|Layer for x coefficient|False
ParameterRaster|map2|Layer for y coefficient|False
ParameterBoolean|-s|Slower but accurate|False
OutputHTML|html|Regression data
12 changes: 5 additions & 7 deletions python/plugins/sextante/grass/description/r.report.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
r.report
r.report - Reports statistics for raster map layers.
r.report - Reports statistics for raster layers.
Raster (r.*)
ParameterMultipleInput|map|Raster map(s) to report on|3.0|False
ParameterMultipleInput|map|Raster layer(s) to report on|3.0|False
ParameterSelection|units|Units|mi;me;k;a;h;c;p
ParameterString|null|Character representing no data cell value|*
ParameterNumber|nsteps|Number of fp subranges to collect stats from|None|None|255
ParameterNumber|nsteps|Number of fp subranges to collect stats from|1|None|255
ParameterBoolean|-h|Suppress page headers|True
ParameterBoolean|-f|Use formfeeds between pages|True
ParameterBoolean|-e|Scientific format|True
ParameterBoolean|-n|Filter out all no data cells|True
ParameterBoolean|-N|Filter out cells where all maps have no data|True
ParameterBoolean|-C|Report for cats fp ranges (fp maps only)|True
ParameterBoolean|-i|Read fp map as integer (use map's quant rules)|True
OutputHTML|output|Name of an output file to hold the report
ParameterBoolean|-N|Filter out cells where all layers have no data|True
OutputHTML|output|Output report file
6 changes: 3 additions & 3 deletions python/plugins/sextante/grass/description/r.resamp.interp.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
r.resamp.interp
r.resamp.interp - Resamples raster map layers to a finer grid using interpolation.
r.resamp.interp - Resamples a raster map layer to a finer grid using interpolation.
Raster (r.*)
ParameterRaster|input|Name of input raster map|False
ParameterRaster|input|Input raster layer|False
ParameterSelection|method|Interpolation method|nearest;bilinear;bicubic
OutputRaster|output|Name for output raster map
OutputRaster|output|Output raster layer
Loading