[GRASS-SVN] r50830 - grass/trunk/scripts/r.buffer
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 16 03:25:39 EST 2012
Author: mmetz
Date: 2012-02-16 00:25:39 -0800 (Thu, 16 Feb 2012)
New Revision: 50830
Modified:
grass/trunk/scripts/r.buffer/r.buffer.py
Log:
compare squared distance for metric != geodesic
Modified: grass/trunk/scripts/r.buffer/r.buffer.py
===================================================================
--- grass/trunk/scripts/r.buffer/r.buffer.py 2012-02-16 07:33:38 UTC (rev 50829)
+++ grass/trunk/scripts/r.buffer/r.buffer.py 2012-02-16 08:25:39 UTC (rev 50830)
@@ -82,13 +82,14 @@
distances = distances.split(',')
distances1 = [scale * float(d) for d in distances]
+ distances2 = [d * d for d in distances1]
s = grass.read_command("g.proj", flags='j')
kv = grass.parse_key_val(s)
if kv['+proj'] == 'longlat':
metric = 'geodesic'
else:
- metric = 'euclidean'
+ metric = 'squared'
grass.run_command('r.grow.distance', input = input, metric = metric,
distance = temp_dist, flags = 'm')
@@ -102,8 +103,12 @@
grass.mapcalc(exp, temp_src = temp_src, input = input)
exp = "$output = if(!isnull($input),$input,%s)"
- for n, dist2 in enumerate(distances1):
- exp %= "if($dist <= %f,%d,%%s)" % (dist2,n + 2)
+ if metric == 'squared':
+ for n, dist2 in enumerate(distances2):
+ exp %= "if($dist <= %f,%d,%%s)" % (dist2,n + 2)
+ else:
+ for n, dist2 in enumerate(distances1):
+ exp %= "if($dist <= %f,%d,%%s)" % (dist2,n + 2)
exp %= "null()"
grass.message(_("Extracting buffers (2/2)..."))
More information about the grass-commit
mailing list