Skip to content

Commit

Permalink
v.random manual: random adjacent polygons example added
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.osgeo.org/grass/grass/trunk@69345 15284696-431f-4ddb-bdfa-cd5b030d7da7
  • Loading branch information
neteler committed Sep 2, 2016
1 parent d1bdd45 commit 9f59a50
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion vector/v.random/v.random.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ <h3>Generating random points in 2D with binary attributes</h3>

Generate 20 random points with binary attributes (only 0 or 1):
<div class="code"><pre>
v.random output=binary_random npoints=20 zmin=0 zmax=1 column='binary' column_type=integer
v.random output=binary_random npoints=20 zmin=0 zmax=1 \
column='binary' column_type=integer
v.db.select binary_random
cat|binary
1|0
Expand Down Expand Up @@ -102,6 +103,45 @@ <h3>Generating random points in 3D</h3>
Random points with different X, Y, and Z coordinates
</center>


<h3>Generating random adjacent polygons</h3>

To generate random adjacent polygons, first the centroids are generated as
points, then a triangulation is run (North Carolina sample dataset:

<div class="code"><pre>
g.region vector=nc_state
v.random output=randpoints6k npoints=6000
v.voronoi input=randpoints6k output=randareas6k
v.info -t randareas6k
v.category randareas6k option=print

# plot vector polygons
d.mon wx0
d.vect randareas6k -c
</pre></div>
<p>
<center>
<img src="vrandom_polygons.png" border=1><br>
Random adjacent polygons from random points (here: used as centroids)
</center>

<p>
To eventually obtain isolated polygons, selected polygons can be extracted with
<em>v.extract</em>.
<p>

These vector polygons can also be rasterized:
<div class="code"><pre>
# rasterize polygons
# note: rastermaps must result in at least 6k pixel in this example
g.region vector=nc_state res=500 -p -a
v.to.rast randareas6k out=randareas6k use=cat
r.colors randareas6k color=random
d.rast randareas6k
</pre></div>


<h3>Random sampling from raster map</h3>

Generate 20 random samples from a raster map:
Expand Down
Binary file added vector/v.random/vrandom_polygons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9f59a50

Please sign in to comment.