[GRASS-SVN] r72619 - grass-addons/grass7/raster/r.tri

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 13 19:28:38 PDT 2018


Author: spawley
Date: 2018-04-13 19:28:38 -0700 (Fri, 13 Apr 2018)
New Revision: 72619

Modified:
   grass-addons/grass7/raster/r.tri/r.tri.py
Log:
Change r.tri standardization to divde over all cells instead of number of neighboring cells so that results are identical to SAGA-GIS

Modified: grass-addons/grass7/raster/r.tri/r.tri.py
===================================================================
--- grass-addons/grass7/raster/r.tri/r.tri.py	2018-04-13 12:06:20 UTC (rev 72618)
+++ grass-addons/grass7/raster/r.tri/r.tri.py	2018-04-14 02:28:38 UTC (rev 72619)
@@ -80,7 +80,7 @@
     p = flags['p']
 
     radius = (size-1)/2
-    neighcells = (size**2)-1
+    ncells = size**2
 
     # store current region settings
     current_reg = Region()
@@ -112,21 +112,21 @@
                 offsets.append((j,i))
 
     # define the calculation term
-    terms = ["abs($dem - $dem[%d,%d])" % d for d in offsets]
+    terms = ["($dem - $dem[%d,%d])^2" % d for d in offsets]
 
     # define the calculation expression
-    expr = "$tri = float(%s" % " + ".join(terms) + ") / $neighcells"
+    expr = "$tri = sqrt((%s" % " + ".join(terms) + ") / $ncells)"
 
     # perform the r.mapcalc calculation with the moving window
     if p:
         output_tmp = temp_map('tmp')
-        gs.mapcalc(expr, tri=output_tmp, dem=dem, neighcells=neighcells)
+        gs.mapcalc(expr, tri=output_tmp, dem=dem, ncells=ncells)
         r.mask(raster=options['input'], quiet=True)
         r.mapcalc('{x}={y}'.format(x=tri, y=output_tmp))
         r.mask(flags='r', quiet=True)
         Region.write(current_reg)
     else:
-        gs.mapcalc(expr, tri=tri, dem=dem, neighcells=neighcells)
+        gs.mapcalc(expr, tri=tri, dem=dem, ncells=ncells)
 
     return 0
 



More information about the grass-commit mailing list