1r.random(1) Grass User's Manual r.random(1)
2
3
4
6 r.random - Creates a raster map layer and vector point map containing
7 randomly located points.
8
10 raster, sampling, vector, random, level1
11
13 r.random
14 r.random --help
15 r.random [-zidb] input=name [cover=name] npoints=number[%]
16 [raster=name] [vector=name] [--overwrite] [--help] [--verbose]
17 [--quiet] [--ui]
18
19 Flags:
20 -z
21 Generate points also for NULL category
22
23 -i
24 Report information about input raster and exit
25
26 -d
27 Generate vector points as 3D points
28
29 -b
30 Do not build topology
31 Do not build topology in points mode
32
33 --overwrite
34 Allow output files to overwrite existing files
35
36 --help
37 Print usage summary
38
39 --verbose
40 Verbose module output
41
42 --quiet
43 Quiet module output
44
45 --ui
46 Force launching GUI dialog
47
48 Parameters:
49 input=name [required]
50 Name of input raster map
51
52 cover=name
53 Name of cover raster map
54
55 npoints=number[%] [required]
56 The number of points to allocate
57
58 raster=name
59 Name for output raster map
60
61 vector=name
62 Name for output vector map
63
65 The program r.random allows the user to create a raster map layer
66 and/or a vector points map containing coordinates of points whose loca‐
67 tions have been randomly determined. The program locates these ran‐
68 domly generated vector points (sites) within the current geographic
69 region and mask (if any), on non-NULL category value data areas within
70 a user-specified raster map layer. If the user sets the -z flag, points
71 will be randomly generated across all cells (even those with NULL val‐
72 ues).
73
74 The category values and corresponding category names already associated
75 with the random point locations in the input map layer are assigned to
76 these points in the raster_output map layer. If the -z is specified,
77 then a unique entry is made for the value used where the input was
78 NULL. This value is at least 1 less than the smallest value in the
79 input raster and is given a medium gray color.
80
82 If a cover raster map is specified and the cover map contains NULL (no
83 data) values, these points are suppressed in the resulting vector_out‐
84 put or raster_output map.
85
86 The vector_output file created by r.random contains vector points that
87 represent the center points of the randomly generated cells. A value
88 attribute contains the cell value of the input raster (or the assigned
89 value when -z is used).
90 If a cover map is additionally specified, a second column covervalue
91 is populated with raster values from the cover map.
92
93 If the user sets the -b flag, vector points are written without topol‐
94 ogy to minimize the required resources. This is suitable input to
95 v.surf.rst and other vector modules.
96
97 The user may specify the quantity of random locations to be generated
98 either as a positive integer (e.g., 10), or as a percentage of the
99 raster map layer’s cells (e.g., 10%, or 3.05%). The number of cells
100 considered for the percentage reflects whether or not the -z flag was
101 given. Options are 0-100; percentages less than one percent may be
102 stated as decimals.
103
104 Flag -i prints the raster map’s name and location, the total number of
105 cells under the current region settings, and the number of NULL valued
106 cells under the current region settings. Then module exits without
107 doing anything. Useful for deciding on the number of sites to have
108 r.random create. WARNING: this feature may be removed in future. Use
109 g.region and r.report instead.
110 g.region -p
111 r.report map=inputmap units=c null=* nsteps=1
112
113 To create random vector point locations within some, but not all,
114 non-zero categories of the input raster map layer, the user must first
115 create a reclassified raster map layer of the original raster map layer
116 (e.g., using the GRASS program r.reclass) that contains only the
117 desired categories, and then use the reclassed raster map layer as
118 input to r.random.
119
121 Random vector elevation points sampled from elevation map in the
122 Spearfish region, result stored in 2D vector map:
123 g.region raster=elevation.10m -p
124 r.random elevation.10m vector=elevrand n=100
125 v.db.select elevrand
126 v.univar elevrand col=value type=point
127
128 Random vector elevation points sampled from elevation map in the
129 Spearfish region with collocated values sampled from landuse map,
130 result stored in 3D vector map:
131 g.region raster=elevation.10m -p
132 r.random -d elevation.10m cover=landcover.30m vector=luserand3d n=100
133 # data output (value: elevation, covervalue: landuse class):
134 v.db.select luserand3d
135 cat|value|covervalue
136 1|1151.406616|81
137 2|1172.121216|71
138 3|1183.219604|71
139 ...
140
142 It’s not possible to use the -i flag and not also specify the n parame‐
143 ter.
144
146 g.region
147 r.reclass
148 v.random
149 v.surf.rst
150
152 Dr. James Hinthorne, GIS Laboratory, Central Washington University
153
154 Modified for GRASS 5.0 by Eric G. Miller
155
156 Cover map support by Markus Neteler, 2007
157
158 Last changed: $Date: 2015-05-11 02:11:34 +0200 (Mon, 11 May 2015) $
159
161 Available at: r.random source code (history)
162
163 Main index | Raster index | Topics index | Keywords index | Graphical
164 index | Full index
165
166 © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
167
168
169
170GRASS 7.4.4 r.random(1)