Skip to content

Commit f2c2114

Browse files
committedOct 13, 2013
[processing] add gdal roughness algorithm (addresses #7201)
1 parent 19c2ed7 commit f2c2114

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed
 

‎python/plugins/processing/gdal/GdalOgrAlgorithmProvider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
from processing.gdal.aspect import aspect
6060
from processing.gdal.tri import tri
6161
from processing.gdal.tpi import tpi
62+
from processing.gdal.roughness import roughness
6263

6364
from processing.gdal.ogr2ogr import Ogr2Ogr
6465
from processing.gdal.ogrinfo import OgrInfo
@@ -110,7 +111,7 @@ def createAlgsList(self):
110111
rgb2pct(), pct2rgb(), merge(), polygonize(), gdaladdo(),
111112
ClipByExtent(), ClipByMask(), contour(), rasterize(), proximity(),
112113
sieve(), fillnodata(), ExtractProjection(), gdal2xyz(),
113-
hillshade(), slope(), aspect(), tri(), tpi(),
114+
hillshade(), slope(), aspect(), tri(), tpi(), roughness(),
114115
# ----- OGR tools -----
115116
OgrInfo(), Ogr2Ogr(), OgrSql(),
116117
]
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# -*- coding: utf-8 -*-
2+
3+
"""
4+
***************************************************************************
5+
roughness.py
6+
---------------------
7+
Date : October 2013
8+
Copyright : (C) 2013 by Alexander Bruy
9+
Email : alexander dot bruy at gmail dot com
10+
***************************************************************************
11+
* *
12+
* This program is free software; you can redistribute it and/or modify *
13+
* it under the terms of the GNU General Public License as published by *
14+
* the Free Software Foundation; either version 2 of the License, or *
15+
* (at your option) any later version. *
16+
* *
17+
***************************************************************************
18+
"""
19+
20+
__author__ = 'Alexander Bruy'
21+
__date__ = 'October 2013'
22+
__copyright__ = '(C) 2013, Alexander Bruy'
23+
24+
# This will get replaced with a git SHA1 when you do a git archive
25+
26+
__revision__ = '$Format:%H$'
27+
28+
29+
from PyQt4.QtGui import *
30+
31+
from processing.core.GeoAlgorithm import GeoAlgorithm
32+
from processing.parameters.ParameterRaster import ParameterRaster
33+
from processing.parameters.ParameterBoolean import ParameterBoolean
34+
from processing.parameters.ParameterNumber import ParameterNumber
35+
from processing.outputs.OutputRaster import OutputRaster
36+
from processing.gdal.GdalUtils import GdalUtils
37+
from processing.tools.system import *
38+
39+
40+
class roughness(GeoAlgorithm):
41+
42+
INPUT = 'INPUT'
43+
BAND = 'BAND'
44+
COMPUTE_EDGES = 'COMPUTE_EDGES'
45+
OUTPUT = 'OUTPUT'
46+
47+
#def getIcon(self):
48+
# filepath = os.path.dirname(__file__) + '/icons/dem.png'
49+
# return QIcon(filepath)
50+
51+
def defineCharacteristics(self):
52+
self.name = 'Roughness'
53+
self.group = '[GDAL] Analysis'
54+
self.addParameter(ParameterRaster(self.INPUT, 'Input layer'))
55+
self.addParameter(ParameterNumber(self.BAND, 'Band number', 1, 99, 1))
56+
self.addParameter(ParameterBoolean(self.COMPUTE_EDGES, 'Compute edges',
57+
False))
58+
59+
self.addOutput(OutputRaster(self.OUTPUT, 'Output file'))
60+
61+
def processAlgorithm(self, progress):
62+
arguments = ['roughness']
63+
arguments.append(unicode(self.getParameterValue(self.INPUT)))
64+
arguments.append(unicode(self.getOutputValue(self.OUTPUT)))
65+
66+
arguments.append('-b')
67+
arguments.append(str(self.getParameterValue(self.BAND)))
68+
69+
if self.getParameterValue(self.COMPUTE_EDGES):
70+
arguments.append('-compute_edges')
71+
72+
GdalUtils.runGdal(['gdaldem',
73+
GdalUtils.escapeAndJoin(arguments)], progress)

0 commit comments

Comments
 (0)
Please sign in to comment.