r.random.cells(1)
π r.random.cells β the manual page, but make it make sense π
okay bestie, sit down, hydrate, and let me tell you about r.random.cells β it's a GRASS GIS User's Manual page, and it's genuinely so fun actually.
β¨ NAME β¨
r.random.cells β generates random cell values with spatial dependence. slay.
π·οΈ 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β lets output files overwrite existing files. yes bestie, permission to be messy π--helpβ prints the usage summary. your little safety net π«Ά--verboseβ verbose module output. it WILL yap and honestly? valid.--quietβ quiet module output. the opposite vibe entirely π€«--uiβ force launches the GUI dialog. for the girlies who like buttons.
πΈ Parameters πΈ
output=name[required] β name for output raster map. you gotta name your baby.distance=float[required] β maximum distance of spatial correlation (value>= 0.0)ncells=integerβ maximum number of cells to be created. Options:1-seed=integerβ random seed, default[random]
π DESCRIPTION π
so r.random.cells generates a random sets of raster cells that are at least distance apart. iconic behavior. the cells are numbered from 1 to the numbers of cells generated, and all other cells are NULL (no data). and listen β random cells will not be generated in areas masked off. it respects the mask, it has boundaries, we love that for it. π¦
π 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. that's the whole vibe check, fr fr.
distance
determines the minimum distance the centers of the random cells will be apart. personal space: enforced. β¨
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. lowkey chaotic but okay.
π 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. so it's not just cute, it's science. π
π 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) β yes, the original says "star", we're keeping it, it's giving typo-as-a-lifestyle:
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. so like, don't go feral with it, bestie.
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. best of both worlds honestly π
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 GIS 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
π 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)
accessed: Saturday Jan 17 05:40:56 2026
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole page, bestie π«Ά this was r.random.cells(1) from the GRASS GIS 8.4.2 Reference Manual β go forth and randomize responsibly, mwah π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· 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