1r.random(1) GRASS GIS 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] [seed=integer] [--overwrite]
17 [--help] [--verbose] [--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
64 seed=integer
65 Seed for rand() function
66
68 The program r.random allows the user to create a raster map layer
69 and/or a vector points map containing coordinates of points whose loca‐
70 tions have been randomly determined. The program locates these ran‐
71 domly generated vector points (sites) within the current geographic
72 region and mask (if any), on non-NULL category value data areas within
73 a user-specified raster map layer. If the user sets the -z flag, points
74 will be randomly generated across all cells (even those with NULL val‐
75 ues).
76
77 The category values and corresponding category names already associated
78 with the random point locations in the input map layer are assigned to
79 these points in the raster_output map layer. If the -z is specified,
80 then a unique entry is made for the value used where the input was
81 NULL. This value is at least 1 less than the smallest value in the
82 input raster and is given a medium gray color.
83
85 If a cover raster map is specified and the cover map contains NULL (no
86 data) values, these points are suppressed in the resulting vector_out‐
87 put or raster_output map.
88
89 The vector_output file created by r.random contains vector points that
90 represent the center points of the randomly generated cells. A value
91 attribute contains the cell value of the input raster (or the assigned
92 value when -z is used).
93 If a cover map is additionally specified, a second column covervalue
94 is populated with raster values from the cover map.
95
96 If the user sets the -b flag, vector points are written without topol‐
97 ogy to minimize the required resources. This is suitable input to
98 v.surf.rst and other vector modules.
99
100 The user may specify the quantity of random locations to be generated
101 either as a positive integer (e.g., 10), or as a percentage of the
102 raster map layer’s cells (e.g., 10%, or 3.05%). The number of cells
103 considered for the percentage reflects whether or not the -z flag was
104 given. Options are 0-100; percentages less than one percent may be
105 stated as decimals.
106
107 Flag -i prints the raster map’s name and location, the total number of
108 cells under the current region settings, and the number of NULL valued
109 cells under the current region settings. Then module exits without
110 doing anything. Useful for deciding on the number of sites to have
111 r.random create. WARNING: this feature may be removed in future. Use
112 g.region and r.report instead.
113 g.region -p
114 r.report map=inputmap units=c null=* nsteps=1
115
116 To create random vector point locations within some, but not all,
117 non-zero categories of the input raster map layer, the user must first
118 create a reclassified raster map layer of the original raster map layer
119 (e.g., using the GRASS program r.reclass) that contains only the
120 desired categories, and then use the reclassed raster map layer as
121 input to r.random.
122
124 Random vector elevation points sampled from elevation map in the
125 Spearfish region, result stored in 2D vector map:
126 g.region raster=elevation.10m -p
127 r.random elevation.10m vector=elevrand n=100
128 v.db.select elevrand
129 v.univar elevrand col=value type=point
130
131 Random vector elevation points sampled from elevation map in the
132 Spearfish region with collocated values sampled from landuse map,
133 result stored in 3D vector map:
134 g.region raster=elevation.10m -p
135 r.random -d elevation.10m cover=landcover.30m vector=luserand3d n=100
136 # data output (value: elevation, covervalue: landuse class):
137 v.db.select luserand3d
138 cat|value|covervalue
139 1|1151.406616|81
140 2|1172.121216|71
141 3|1183.219604|71
142 ...
143
145 It’s not possible to use the -i flag and not also specify the n parame‐
146 ter.
147
149 g.region
150 r.reclass
151 v.random
152 v.surf.rst
153
155 Dr. James Hinthorne, GIS Laboratory, Central Washington University
156
157 Modified for GRASS 5.0 by Eric G. Miller
158
159 Cover map support by Markus Neteler, 2007
160
162 Available at: r.random source code (history)
163
164 Main index | Raster index | Topics index | Keywords index | Graphical
165 index | Full index
166
167 © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
168
169
170
171GRASS 7.8.5 r.random(1)