r.random.cells(1grass)
β¨ r.random.cells β¨
okay bestie, welcome to the <rainbow>r.random.cells</rainbow> page from the GRASS User's Manual π this one's a raster girlie, and she's all about that spatial dependence β no cap.
πΈ NAME πΈ
r.random.cells β generates random cell values with spatial dependence. periodt. π
π·οΈ KEYWORDS π·οΈ
raster, sampling, random, autocorrelation π¦
π SYNOPSIS π
r.random.cells
r.random.cells --help
r.random.cells output=name distance=float [ncells=integer]
[seed=integer] [--overwrite] [--help] [--verbose] [--quiet] [--ui]
π© Flags π©
--overwriteβ allow output files to overwrite existing files (yes she will absolutely replace your old raster, be so fr) π--helpβ print usage summary π--verboseβ verbose module output (she talks a LOT) π£οΈ--quietβ quiet module output (she's giving mysterious, silent, lowkey iconic) π€«--uiβ force launching GUI dialog π₯οΈ
π§ Parameters π§
output=name[required] β name for output raster map πdistance=float[required] β maximum distance of spatial correlation (value >= 0.0) πncells=integerβ maximum number of cells to be created. Options:1-π’seed=integerβ seed value for the random number generator. Using the same seed ensures identical results, while a randomly generated seed produces different outcomes in each run. π²
π« DESCRIPTION π«
r.random.cells generates a random sets of raster cells that are at least distance apart. The cells are numbered from 1 to the numbers of cells generated, all other cells are NULL (no data). Random cells will not be generated in areas masked off. π«Ά
π Detailed parameter description π
output
Random cells. Each random cell has a unique non-zero cell value ranging from 1 to the number of cells generated. The heuristic for this algorithm is to randomly pick cells until there are no cells outside of the chosen cell's buffer of radius distance. π―
distance
Determines the minimum distance the centers of the random cells will be apart. no closer than that, bestie, that's the whole point π
seed
Specifies the random seed that r.random.cells will use to generate the cells. If the random seed is not given, r.random.cells will get a seed from the process ID number. so like, chaotic-by-default energy π
π NOTES π
The original purpose for this program was to generate independent random samples of cells in a study area. The distance value is the amount of spatial autocorrelation for the map being studied. fr fr that's what's happening here π§
π EXAMPLES π
Random cells in given distances
North Carolina sample dataset example:
g.region n=228500 s=215000 w=630000 e=645000 res=100 -p
r.random.cells output=random_500m distance=500
Limited number of random points
Here is another example where we will create given number of vector points with the given minimal distances. Let's star with setting the region (we use large cells here):
g.region raster=elevation
g.region rows=20 cols=20 -p
Then we generate random cells and we limit their count to 20:
r.random.cells output=random_cells distance=1500 ncells=20 seed=200
Finally, we convert the raster cells to points using r.to.vect module:
r.to.vect input=random_cells output=random_points type=point
An example of the result is at the Figure below on the left in comparison with the result without the cell limit on the right. π
Additionally, we can use v.perturb module to add random spatial deviation to their position so that they are not perfectly aligned with the grid. We cannot perturb the points too much, otherwise we might seriously break the minimal distance we set earlier. β οΈ (like genuinely, don't get greedy with the perturbation)
v.perturb input=random_points output=random_points_moved parameters=50 seed=200
In the above examples, we were using fixed seed. This is advantageous when we want to generate (pseudo) random data, but we want to get reproducible results at the same time. chef's kiss reproducibility π
Figure: Generated cells with limited number of cells (upper left), derived vector points (lower left), cells without a count limit (upper right) and corresponding vector points (lower right)
π REFERENCES π
Random Field Software for GRASS by Chuck Ehlschlaeger
As part of my dissertation, I put together several programs that help GRASS (4.1 and beyond) develop uncertainty models of spatial data. I hope you find it useful and dependable. The following papers might clarify their use:
- Ehlschlaeger, C.R., Shortridge, A.M., Goodchild, M.F., 1997. Visualizing spatial data uncertainty using animation. Computers & Geosciences 23, 387-395. doi:10.1016/S0098-3004(97)00005-8
- Modeling Uncertainty in Elevation Data for Geographical Analysis, by Charles R. Ehlschlaeger, and Ashton M. Shortridge. Proceedings of the 7th International Symposium on Spatial Data Handling, Delft, Netherlands, August 1996.
- Dealing with Uncertainty in Categorical Coverage Maps: Defining, Visualizing, and Managing Data Errors, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, Workshop on Geographic Information Systems at the Conference on Information and Knowledge Management, Gaithersburg MD, 1994.
- Uncertainty in Spatial Data: Defining, Visualizing, and Managing Data Errors, by Charles Ehlschlaeger and Michael Goodchild. Proceedings, GIS/LIS'94, pp. 246-253, Phoenix AZ, 1994.
π SEE ALSO π
r.random.surface, r.random, v.random, r.to.vect, v.perturb β go read those too, they slay in their own way π
π AUTHOR π
Charles Ehlschlaeger; National Center for Geographic Information and Analysis, University of California, Santa Barbara π
πΎ SOURCE CODE πΎ
Available at: r.random.cells source code (history)
Latest change: Friday Aug 08 09:39:19 2025 in commit: ed72c71d8580e872cd6fd345c84a15c324764465
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
okay that's the whole thing bestie, iykyk π big love and infinite gratitude to the GRASS Development Team β Β© 2003-2026, this is GRASS 8.5.0 Reference Manual vibes, and the page lives at GRASS 8.5.0 for r.random.cells(1grass). go make some spatially-dependent random cells, you're gonna ate π«Άβ¨
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms