Skip to content

Commit

Permalink
r.random.walk: Add module to create random walks (#606)
Browse files Browse the repository at this point in the history
The module implements a simple 2D random walk. The module currently allows for 4 and 8 directional walks for n number of steps over a given computational region. The module runs in parallel when computing an average walk from a single starting location or an average walk from multiple starting locations.
  • Loading branch information
cwhite911 committed Jun 4, 2023
1 parent ca3ffd9 commit d50ebe3
Show file tree
Hide file tree
Showing 7 changed files with 697 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/raster/r.random.walk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MODULE_TOPDIR = ../..

PGM = r.random.walk

include $(MODULE_TOPDIR)/include/Make/Script.make

default: script
40 changes: 40 additions & 0 deletions src/raster/r.random.walk/r.random.walk.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<h2>DESCRIPTION</h2>
The <em>r.random.walk</em> module generates a 2D random walk across the current computational region.
The module provides control of the number of steps and directions (4 or 8) a walker can take and allows
the walker's behavior to be set to be self-avoiding (Madras et al., 1996) or allow revisits. The output displays
the frequency the walker visited each cell or the average frequency. The module can run multiple walks in
parallel. It either samples the same starting location for each walk or generates a unique starting position
for each walker.

<h2>EXAMPLE</h2>
Using the North Carolina full sample dataset:


<div class="code"><pre>
# set computational region
g.region raster=elevation -p

# calculate smoothed random walk from a single starting locations.
r.random.walk -at output=random_walk_smooth_paths directions=8 steps=100000 memory=1800 seed=1 nprocs=6 nwalkers=100
</pre></div>
<center>
<img src="r_random_walk_example.png" width=600 border=0><br>
Smoothed random walk (Single Starting Location)
</center>

<div class="code"><pre>
# calculate smoothed random walk from a multiple starting locations.
r.random.walk -as output=random_walk_smooth directions=8 steps=100000 memory=1800 nprocs=6 nwalkers=100
</pre></div>

<center>
<img src="r_random_walk_example_2.png" width=600 border=0><br>
Smoothed random walk (Multiple Starting Locations)
</center>

<h2>SEE ALSO</h2>
<a href="https://grass.osgeo.org/grass-stable/manuals/r.surf.fractal.html">r.surf.fractal</a>,
<a href="https://grass.osgeo.org/grass-stable/manuals/r.surf.random.html">r.surf.random</a>

<h2>AUTHOR</h2>
Corey T. White, <a href="https://geospatial.ncsu.edu/geoforall/">NCSU GeoForAll Lab</a>

0 comments on commit d50ebe3

Please sign in to comment.