Skip to content

Commit b86bbe5

Browse files
author
volayaf
committed
added some gdal algs
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@69 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 69bc4a0 commit b86bbe5

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/sextante/gdal/GdalAlgorithmProvider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from sextante.gdal.translate import translate
1414
from sextante.gdal.pct2rgb import pct2rgb
1515
from sextante.gdal.merge import merge
16+
from sextante.gdal.polygonize import polygonize
1617

1718
class GdalAlgorithmProvider(AlgorithmProvider):
1819

@@ -50,7 +51,7 @@ def _loadAlgorithms(self):
5051
def createAlgsList(self):
5152
#First we populate the list of algorihtms with those created extending
5253
#GeoAlgorithm directly (those that execute GDAL using the console)
53-
self.preloadedAlgs = [nearblack(), information(), warp(), translate(), rgb2pct(), pct2rgb(), merge()]
54+
self.preloadedAlgs = [nearblack(), information(), warp(), translate(), rgb2pct(), pct2rgb(), merge(), polygonize()]
5455
#And then we add those that are created as python scripts
5556
folder = self.scriptsFolder()
5657
for descriptionFile in os.listdir(folder):

src/sextante/gdal/polygonize.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from PyQt4 import QtGui
2+
from sextante.core.GeoAlgorithm import GeoAlgorithm
3+
from sextante.parameters.ParameterRaster import ParameterRaster
4+
import os
5+
from sextante.gdal.GdalUtils import GdalUtils
6+
from sextante.parameters.ParameterString import ParameterString
7+
from sextante.outputs.OutputVector import OutputVector
8+
9+
class polygonize(GeoAlgorithm):
10+
11+
INPUT = "INPUT"
12+
OUTPUT = "OUTPUT"
13+
FIELD = "FIELD"
14+
15+
def getIcon(self):
16+
filepath = os.path.dirname(__file__) + "/icons/polygonize.png"
17+
return QtGui.QIcon(filepath)
18+
19+
def defineCharacteristics(self):
20+
self.name = "polygonize"
21+
self.group = "Conversion"
22+
self.addParameter(ParameterRaster(polygonize.INPUT, "Input layer", False))
23+
self.addParameter(ParameterString(polygonize.FIELD, "Output field name", "Value"))
24+
self.addOutput(OutputVector(polygonize.OUTPUT, "Output layer"))
25+
26+
def processAlgorithm(self, progress):
27+
commands = ["polygonize"]
28+
commands.append(self.getParameterValue(polygonize.INPUT))
29+
commands.append("-f")
30+
commands.append("ESRI Shapefile")
31+
commands.append(self.getOutputValue(polygonize.OUTPUT))
32+
commands.append(self.getParameterValue(polygonize.FIELD))
33+
34+
GdalUtils.runGdal(commands, progress)

0 commit comments

Comments
 (0)