r.cross(1grass)
β¨ r.cross β the GRASS manual, but make it bestie π
okay so this is r.cross, from the GRASS User's Manual (that's the r.cross(1grass) page, iykyk). it's a lil raster module and honestly? it's giving math girlie. let's get into it π
π NAME π
r.cross β Creates a cross product of the category values from multiple raster map layers.
π·οΈ KEYWORDS π·οΈ
raster, statistics
π¦ SYNOPSIS π¦
r.cross
r.cross --help
r.cross [-z] input=string[,string,...] output=name [--overwrite]
[--help] [--verbose] [--quiet] [--ui]
π Flags π
-zβ Non-NULL data only--overwriteβ Allow output files to overwrite existing files--helpβ Print usage summary--verboseβ Verbose module output--quietβ Quiet module output--uiβ Force launching GUI dialog
πΈ Parameters πΈ
input=string[,string,...][required] β Names of 2-30 input raster mapsoutput=name[required] β Name for output raster map
π DESCRIPTION π
so r.cross makes an output raster map layer that represents all the unique combinations of category values from the raster input layers (input=name,name,name, ...). no cap, that's literally what it does.
you gotta give it at least two input map layers, but not more than 30 β so 2 to 30 bestie, that's the vibe check. and yes, you ALSO have to pick a name for the output raster map layer that r.cross is gonna create, because it's not gonna name itself obviously π
β¨ OPTIONS β¨
with the -z flag, NULL values are not crossed. translation: if a NULL value shows up in any input data layer, that whole combination gets ignored β even if the other data layers are sitting there with perfectly good non-NULL data. so rude. in the example down below, using the -z option would cause 3 categories to be generated instead of 5. yeah, big difference.
if the -z flag is not specified, then map layer combinations where some values are NULL still get a unique category value assigned in the resulting output map. so nothing gets left out, they all get a lil seat at the table π«Ά
category values in the new output map layer will be the cross-product of the category values from those existing input map layers. math! iconic! π
π EXAMPLE π
okay imagine this: using two raster map layers, these are the combinations that occur:
map1 map2
___________
NULL 1
NULL 2
1 1
1 2
2 4
r.cross would produce a new raster map layer with 5 categories:
map1 map2 output
____________________
NULL 1 0
NULL 2 1
1 1 2
1 2 3
2 4 4
Note: the actual category value assigned to a particular combination in the result map layer is dependent on the order in which the combinations occur in the input map layer data and can be considered essentially random. the example given here is illustrative only. so don't come for me if your numbers look different bestie, it's not a bug it's a feature π
πΈ SUPPORT FILES πΈ
the category file created for the output raster map layer describes the combinations of input map layer category values that generated each category. in the example above, the category labels would be:
category category
value label
______________________________
0 layer1(0) layer2(1)
1 layer1(0) layer2(2)
2 layer1(1) layer2(1)
3 layer1(1) layer2(2)
4 layer1(2) layer2(4)
a random color table is also generated for the output map layer. cute AND functional, we love that for us π
π SEE ALSO π
r.covar, r.stats
π AUTHOR π
Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
π₯ SOURCE CODE π₯
Available at: r.cross source code (history)
Latest change: Thursday May 08 20:58:05 2025 in commit: 4144ba81fa125e1549fc52e1cf5feb4fa004be8b
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie, you ate that π this was GRASS 8.5.0, Β© 2003-2026 GRASS Development Team, straight outta the GRASS 8.5.0 Reference Manual β now go cross some rasters, no cap π¦β¨
π¦ 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