Skip to content

Commit

Permalink
added some gdal algs
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@69 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf committed Apr 11, 2012
1 parent 69bc4a0 commit b86bbe5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/sextante/gdal/GdalAlgorithmProvider.py
Expand Up @@ -13,6 +13,7 @@
from sextante.gdal.translate import translate
from sextante.gdal.pct2rgb import pct2rgb
from sextante.gdal.merge import merge
from sextante.gdal.polygonize import polygonize

class GdalAlgorithmProvider(AlgorithmProvider):

Expand Down Expand Up @@ -50,7 +51,7 @@ def _loadAlgorithms(self):
def createAlgsList(self):
#First we populate the list of algorihtms with those created extending
#GeoAlgorithm directly (those that execute GDAL using the console)
self.preloadedAlgs = [nearblack(), information(), warp(), translate(), rgb2pct(), pct2rgb(), merge()]
self.preloadedAlgs = [nearblack(), information(), warp(), translate(), rgb2pct(), pct2rgb(), merge(), polygonize()]
#And then we add those that are created as python scripts
folder = self.scriptsFolder()
for descriptionFile in os.listdir(folder):
Expand Down
34 changes: 34 additions & 0 deletions src/sextante/gdal/polygonize.py
@@ -0,0 +1,34 @@
from PyQt4 import QtGui
from sextante.core.GeoAlgorithm import GeoAlgorithm
from sextante.parameters.ParameterRaster import ParameterRaster
import os
from sextante.gdal.GdalUtils import GdalUtils
from sextante.parameters.ParameterString import ParameterString
from sextante.outputs.OutputVector import OutputVector

class polygonize(GeoAlgorithm):

INPUT = "INPUT"
OUTPUT = "OUTPUT"
FIELD = "FIELD"

def getIcon(self):
filepath = os.path.dirname(__file__) + "/icons/polygonize.png"
return QtGui.QIcon(filepath)

def defineCharacteristics(self):
self.name = "polygonize"
self.group = "Conversion"
self.addParameter(ParameterRaster(polygonize.INPUT, "Input layer", False))
self.addParameter(ParameterString(polygonize.FIELD, "Output field name", "Value"))
self.addOutput(OutputVector(polygonize.OUTPUT, "Output layer"))

def processAlgorithm(self, progress):
commands = ["polygonize"]
commands.append(self.getParameterValue(polygonize.INPUT))
commands.append("-f")
commands.append("ESRI Shapefile")
commands.append(self.getOutputValue(polygonize.OUTPUT))
commands.append(self.getParameterValue(polygonize.FIELD))

GdalUtils.runGdal(commands, progress)

0 comments on commit b86bbe5

Please sign in to comment.