[GRASS-SVN] r55465 - grass-addons/grass6/raster/r.rdfilter

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Mar 20 04:53:14 PDT 2013


Author: jradinger
Date: 2013-03-20 04:53:13 -0700 (Wed, 20 Mar 2013)
New Revision: 55465

Modified:
   grass-addons/grass6/raster/r.rdfilter/r.rdfilter.py
Log:
stop criterion (stop points based on r.cost) implemented.
Working, but not extensively tested yet.

Modified: grass-addons/grass6/raster/r.rdfilter/r.rdfilter.py
===================================================================
--- grass-addons/grass6/raster/r.rdfilter/r.rdfilter.py	2013-03-20 08:19:55 UTC (rev 55464)
+++ grass-addons/grass6/raster/r.rdfilter/r.rdfilter.py	2013-03-20 11:53:13 UTC (rev 55465)
@@ -22,6 +22,13 @@
 #% required: yes
 #%end
 #%option
+#% key: stop_points
+#% type: string
+#% gisprompt: old,vector, vector
+#% description: stop point vector for r.cost
+#% required: no
+#%end
+#%option
 #% key: output
 #% type: string
 #% gisprompt: new,cell,raster
@@ -87,6 +94,7 @@
 	# Defining variables
 	input_map = options['input']
 	distance = options['distance']
+	stop_points = options['stop_points']
 	if options['output']:
 		output_map = str(options['output'])
 	else:
@@ -135,13 +143,23 @@
 
 		
 		# creating "focal distance mask" (using r.cost with a specified distance as input)
-		grass.run_command("r.cost",
-					flags = 'n',
-					overwrite = True,
-					max_cost = distance,
-					input = "tmp"+str(os.getpid()),
-					output = "distance_mask"+str(os.getpid()),
-					coordinate = coors)
+		if options['stop_points']:
+			grass.run_command("r.cost",
+						flags = 'n',
+						overwrite = True,
+						max_cost = distance,
+						stop_points = stop_points,
+						input = "tmp"+str(os.getpid()),
+						output = "distance_mask"+str(os.getpid()),
+						coordinate = coors)
+		else:			
+			grass.run_command("r.cost",
+						flags = 'n',
+						overwrite = True,
+						max_cost = distance,
+						input = "tmp"+str(os.getpid()),
+						output = "distance_mask"+str(os.getpid()),
+						coordinate = coors)
 			
 		# creating "masked map" based on input
 		grass.mapcalc("$masked_map= if(!isnull($distance_mask),$input_map,null())",



More information about the grass-commit mailing list