[GRASS-SVN] r56477 - grass-addons/grass6/raster/r.fidimo
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 29 07:21:04 PDT 2013
Author: jradinger
Date: 2013-05-29 07:21:04 -0700 (Wed, 29 May 2013)
New Revision: 56477
Modified:
grass-addons/grass6/raster/r.fidimo/r.fidimo.py
Log:
Changed distance raster (pseudo elevation map) to a buffered distance raster.
This is then input to r.watershed. Should solve the problem with small river segments.
Modified: grass-addons/grass6/raster/r.fidimo/r.fidimo.py
===================================================================
--- grass-addons/grass6/raster/r.fidimo/r.fidimo.py 2013-05-29 13:46:17 UTC (rev 56476)
+++ grass-addons/grass6/raster/r.fidimo/r.fidimo.py 2013-05-29 14:21:04 UTC (rev 56477)
@@ -40,10 +40,6 @@
#% required: no
#% guisection: Stream parameters
#%end
-#%Flag
-#% key: s
-#% description: Remove small river segments
-#%end
#%option
#% key: n_source
#% type: string
@@ -401,36 +397,29 @@
input = "river_raster_tmp_%d" % os.getpid(),
output = "distance_raster_tmp_%d" % os.getpid(),
coordinate = coors)
- grass.run_command("r.watershed",
- flags = 'm', #depends on memory!!
- elevation = "distance_raster_tmp_%d" % os.getpid(),
- drainage = "flow_direction_tmp_%d" % os.getpid(),
- stream = "stream_segments_tmp_%d" % os.getpid(),
- threshold = "2",
- overwrite = True)
+ largest_cost_value = grass.raster_info("distance_raster_tmp_%d" % os.getpid())['max']
+ n_buffer_cells = 3
+ grass.run_command("r.buffer",
+ overwrite=True,
+ input="distance_raster_tmp_%d" % os.getpid(),
+ output="buffered_river_tmp_%d" % os.getpid(),
+ distances=n_buffer_cells*res)
- #!!!! Here Problem when 1 cell river section is in mainstem: gap in the middle of the river!
- # Maybe solve with flag to choose either leave or remove small river sections!
- #Removing small (1 cell) river sections and re-calculate distance raster and flow direction
- if flags['s']:
- grass.mapcalc("$river_raster = if($stream_segments>=0, $river_raster, null())",
- river_raster = "river_raster_tmp_%d" % os.getpid(),
- stream_segments = "stream_segments_tmp_%d" % os.getpid())
- grass.run_command("r.cost",
- flags = 'n',
- overwrite = True,
- input = "river_raster_tmp_%d" % os.getpid(),
- output = "distance_raster_tmp_%d" % os.getpid(),
- coordinate = coors)
- grass.run_command("r.watershed",
- flags = 'm', #depends on memory!!
- elevation = "distance_raster_tmp_%d" % os.getpid(),
- drainage = "flow_direction_tmp_%d" % os.getpid(),
- overwrite = True)
-
+ grass.mapcalc("$distance_raster_buffered_tmp = if($buffered_river_tmp==2,$largest_cost_value*2,$distance_raster_tmp)",
+ distance_raster_buffered_tmp = "distance_raster_buffered_tmp_%d" % os.getpid(),
+ buffered_river_tmp = "buffered_river_tmp_%d" % os.getpid(),
+ largest_cost_value = "largest_cost_value_%d" % os.getpid(),
+ distance_raster_tmp = "distance_raster_tmp_%d" % os.getpid())
+ grass.run_command("r.watershed", #??? Set flag "s" for single flow ???
+ flags = 'm', #depends on memory!! #
+ elevation = "distance_raster_buffered_tmp_%d" % os.getpid(),
+ drainage = "flow_direction_tmp_%d" % os.getpid(),
+ stream = "stream_segments_tmp_%d" % os.getpid(),
+ threshold = n_buffer_cells,
+ overwrite = True)
#Calculation of stream order (Shreve/Strahler)
@@ -443,8 +432,6 @@
-
-
################ Preparation Source Populations ################
#Defining source points either as random points in river or from input raster
More information about the grass-commit
mailing list