1v.random(1)                   Grass User's Manual                  v.random(1)
2
3
4

NAME

6       v.random  - Generates random 2D/3D vector points.
7

KEYWORDS

9       vector,  sampling, statistics, random, point pattern, stratified random
10       sampling, level1
11

SYNOPSIS

13       v.random
14       v.random --help
15       v.random   [-zab]    output=name    npoints=integer     [restrict=name]
16       [layer=string]      [cats=range]     [where=sql_query]     [zmin=float]
17       [zmax=float]    [seed=integer]    [column=name]    [column_type=string]
18       [--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]
19
20   Flags:
21       -z
22           Create 3D output
23
24       -a
25           Generate  n  points  for  each  individual  area (requires restrict
26           parameter)
27
28       -b
29           Do not build topology
30           Advantageous when handling a large number of points
31
32       --overwrite
33           Allow output files to overwrite existing files
34
35       --help
36           Print usage summary
37
38       --verbose
39           Verbose module output
40
41       --quiet
42           Quiet module output
43
44       --ui
45           Force launching GUI dialog
46
47   Parameters:
48       output=name [required]
49           Name for output vector map
50
51       npoints=integer [required]
52           Number of points to be created
53
54       restrict=name
55           Name of input vector map
56           Restrict points to areas in input vector
57
58       layer=string
59           Layer number or name (’-1’ for all layers)
60           A single vector map can be connected to multiple  database  tables.
61           This  number  determines  which table to use. When used with direct
62           OGR access this is the layer name.
63           Default: -1
64
65       cats=range
66           Category values
67           Example: 1,3,7-9,13
68
69       where=sql_query
70           WHERE conditions of SQL statement without ’where’ keyword
71           Example: income < 1000 and population >= 10000
72
73       zmin=float
74           Minimum z height (needs -z flag or column name)
75           Default: 0.0
76
77       zmax=float
78           Maximum z height (needs -z flag or column name)
79           Default: 0.0
80
81       seed=integer
82           The seed to initialize the random generator. If not set the process
83           ID is used
84
85       column=name
86           Name of column for z values
87           Writes z values to column
88
89       column_type=string
90           Type of column for z values
91           Options: integer, double precision
92           Default: double precision
93

DESCRIPTION

95       v.random  randomly  generates  vector  points within the current region
96       using the selected random number generator.
97
98       v.random can generate also 3D vector points or write  random  value  to
99       attribute  table.  Point  height range or attribute value range is con‐
100       trolled by specifying  zmin  and  zmax  options.   Both  z  values  are
101       included in range (zmin <= z <= zmax). Generated random attribute value
102       type can be controlled by column_type.  Use  integer  column  type  for
103       integers  and double precision for floating point numbers. Integer val‐
104       ues are calculated by rounding random floating point number.
105
106       To produce repeatable results a random seed can be set using the option
107       seed.
108
109   Restriction to vector areas
110       If an restrict vector map with areas is specified, the location of ran‐
111       dom points is  restricted  to  the  selected  areas.  By  default,  the
112       requested number of points are distributed across all areas.
113
114       If  the  -a  flag is given, the requested number of points is generated
115       for each individual area. For example, if 20 points should be generated
116       and  the input map has 100 individual areas, 2000 points will be gener‐
117       ated in total.
118

EXAMPLES

120       All examples are based on the North Carolina sample dataset.
121
122   Generating random points in 2D
123       Generate 20 random points with binary attributes (only 0 or 1):
124       v.random output=binary_random npoints=20 zmin=0 zmax=1 column=’binary’
125       v.db.select binary_random
126       cat|binary
127       1|0.63495
128       2|0.233421
129       3|0.489302
130       4|0.748264
131       5|0.505556
132       6|0.32975
133       [...]
134       v.univar -d binary_random
135       Calculating geometric distances between 20 primitives...
136       [...]
137       minimum: 148.515
138       maximum: 16572.8
139       [...]
140
141   Generating random points in 2D with binary attributes
142       Generate 20 random points with binary attributes (only 0 or 1):
143       v.random output=binary_random npoints=20 zmin=0 zmax=1 column=’binary’ column_type=integer
144       v.db.select binary_random
145       cat|binary
146       1|0
147       2|0
148       3|0
149       4|0
150       5|1
151       6|0
152       [...]
153
154   Generating random points in 3D
155       Generate 20 random 3D points using a specific random seed:
156       v.random seed=52 output=height_random npoints=40 zmin=110 zmax=170 -z
157       v.univar -d height_random
158       Calculating geometric distances between 40 primitives...
159       [...]
160       minimum: 334.889
161       maximum: 18351.9
162       range: 18017
163       sum: 5.38425e+06
164       mean: 7266.2
165       mean of absolute values: 7266.2
166       population standard deviation: 3563.95
167       [...]
168       skewness: 0.34703
169
170       Random points with different X, Y, and Z coordinates
171
172   Generating random points in selected polygons
173       Generate 3 random points only in selected polygons  ("RALEIGH"  related
174       ZIP code areas):
175       v.random restrict=zipcodes_wake output=zipcodes_local_random_n3 npoints=3 where="ZIPNAME = ’RALEIGH’" -a
176       # visualization
177       d.mon wx0
178       d.vect zipcodes_wake
179       d.vect zipcodes_wake fcolor=yellow where="ZIPNAME = ’RALEIGH’"
180       d.vect zipcodes_local_random_n3 color=red icon=basic/circle
181       Fixed number of random points generated in selected polygons
182
183   Generating random adjacent polygons
184       To generate random adjacent polygons, first the centroids are generated
185       as points, then a triangulation is run (North Carolina sample dataset:
186       g.region vector=nc_state
187       v.random output=randpoints6k npoints=6000
188       v.voronoi input=randpoints6k output=randareas6k
189       v.info -t randareas6k
190       v.category randareas6k option=print
191       # plot vector polygons
192       d.mon wx0
193       d.vect randareas6k -c
194
195       Random adjacent polygons from random points (here: used as centroids)
196
197       To eventually  obtain  isolated  polygons,  selected  polygons  can  be
198       extracted with v.extract.
199
200       These vector polygons can also be rasterized:
201       # rasterize polygons
202       # note: rastermaps must result in at least 6k pixel in this example
203       g.region vector=nc_state res=500 -p -a
204       v.to.rast randareas6k out=randareas6k use=cat
205       r.colors randareas6k color=random
206       d.rast randareas6k
207
208   Random sampling from raster map
209       Generate 20 random samples from a raster map:
210       g.region -p raster=elevation
211       v.random output=random_samples npoints=20
212       v.db.addtable map=random_samples columns=’cat INTEGER, sample DOUBLE PRECISION’
213       v.what.rast map=random_samples raster=elevation column=sample
214       v.db.select random_samples
215       cat|sample
216       1|103.9935
217       2|129.1266
218       3|96.01388
219       [...]
220
221   Random sampling from vector map
222       Generate  20 random points and sample attribute data from geology (vec‐
223       tor) map:
224       g.region -p vector=geology
225       v.random output=random_samples npoints=20
226       v.db.addtable map=random_samples columns=’cat integer, geology varchar(100)’
227       v.what.vect map=random_samples column=geology query_map=geology query_layer=1 query_column=GEO_NAME
228       v.db.select random_samples
229       cat|geology
230       1|PzZm
231       2|
232       3|Zatm
233       [...]
234
235   Stratified random sampling: Random sampling from vector map by attribute
236       Generate 20 random points restricted to forested areas:
237       g.region -p raster=landclass96
238       r.to.vect -v input=landclass96 output=landclass96 type=area
239       v.random restrict=landclass96 output=random_samples npoints=20 where="label = ’forest’" layer=1
240
241       Random points only sampled in forested areas  (stratified  random  sam‐
242       pling)
243
244   Stratified  random  sampling:  Random sampling from vector map with spatial
245       constraints
246       Generating n points for each individual area: in this example two  ran‐
247       dom points in each water body:
248       g.region -p raster=landclass96
249       r.to.vect -v input=landclass96 output=landclass96 type=area
250       v.random restrict=landclass96 output=random_samples npoints=2 where="label = ’water’" layer=1 -a
251
252       Two  random  points  sampled  in each individual water body (stratified
253       random sampling)
254

SEE ALSO

256        g.region,  r.random,  v.db.addtable,  v.perturb,  v.sample,  v.univar,
257       v.what.rast, v.what.vect
258
259       SQL support in GRASS GIS
260

AUTHOR

262       James Darrell McCauley <darrell@mccauley-usa.com>,
263       when he was at: Agricultural Engineering Purdue University
264
265       Last changed: $Date: 2018-04-06 19:51:18 +0200 (Fri, 06 Apr 2018) $
266

SOURCE CODE

268       Available at: v.random source code (history)
269
270       Main  index  | Vector index | Topics index | Keywords index | Graphical
271       index | Full index
272
273       © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
274
275
276
277GRASS 7.4.4                                                        v.random(1)
Impressum