[GRASS-SVN] r62268 - grass-addons/grass7/raster/r.gradient
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Oct 16 02:43:08 PDT 2014
Author: lucadelu
Date: 2014-10-16 02:43:08 -0700 (Thu, 16 Oct 2014)
New Revision: 62268
Modified:
grass-addons/grass7/raster/r.gradient/r.gradient.py
Log:
r.gradient: add check if percentile is set or not, fix some type errors
Modified: grass-addons/grass7/raster/r.gradient/r.gradient.py
===================================================================
--- grass-addons/grass7/raster/r.gradient/r.gradient.py 2014-10-16 09:09:33 UTC (rev 62267)
+++ grass-addons/grass7/raster/r.gradient/r.gradient.py 2014-10-16 09:43:08 UTC (rev 62268)
@@ -60,7 +60,7 @@
"""Calculate the oblique gradient"""
cols = reg['cols']
rows = reg['rows']
- first_perc = ma * perc / 100.
+ first_perc = ma * float(perc) / 100.
dif_cols_first = (first_perc - mi) / float(cols-1)
dif_rows_first = (first_perc - mi) / float(rows-1)
dif_rows_last = (ma - first_perc) / float(rows-1)
@@ -101,17 +101,24 @@
return False
+def checkPercentile(per, di):
+ """Check if percentile option is set with the oblique directions"""
+ if not per and di in ['NW-SE', 'NE-SW', 'SW-NE', 'SE-NW']:
+ grass.fatal("Percentile option has to be set with {dire} direction". format(dire=di))
+
+
def main():
"""Main function"""
regiondict = grass.region()
output = options['output']
values = options['range'].split(',')
- NewMin = values[0].strip()
- NewMax = values[1].strip()
+ NewMin = int(values[0].strip())
+ NewMax = int(values[1].strip())
percentile = options['percentile']
direction = options['direction']
+ checkPercentile(percentile, direction)
# And now we can calculate the graded rasters
# for gradient of rows
if direction == 'N-S':
More information about the grass-commit
mailing list