r.cross(1)

✨ r.cross β€” the manual, but make it make sense ✨

okay bestie, welcome to the GRASS GIS User's Manual page for r.cross(1) πŸ’– this is the one where we take a bunch of raster maps and smash their category values together into one glorious cross-product map. it's giving matchmaker energy fr fr 🫢


🌸 NAME 🌸

r.cross β€” creates a cross product of the category values from multiple raster map layers. no cap, that's literally the whole job πŸŽ€


πŸ”‘ 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. yes queen, skip the NULLs entirely.
  • --overwrite β€” Allow output files to overwrite existing files. live dangerously, bestie.
  • --help β€” Print usage summary. when u need the cliffnotes.
  • --verbose β€” Verbose module output. it will NOT stop talking and honestly? iconic.
  • --quiet β€” Quiet module output. the introvert setting 🀫
  • --ui β€” Force launching GUI dialog. for when clicking > typing.

🌈 Parameters 🌈

  • input=string[,string,...] [required] β€” Names of 2-30 input raster maps. that's right, minimum TWO, maximum THIRTY. no solo missions, no crowd of 31 πŸ‘‘
  • output=name [required] β€” Name for output raster map. u gotta name ur baby.

πŸ’– DESCRIPTION πŸ’–

so here's the tea: r.cross creates an output raster map layer representing all unique combinations of category values in the raster input layers (input=name,name,name, ...). it's literally crossing everything with everything, and the results are lowkey mesmerizing ✨

the rules tho: at least two, but not more than 30, input map layers must be specified. don't try to be extra with 31, it's not the vibe. and the user must also specify a name to be assigned to the output raster map layer created by r.cross. no output name, no output. periodt.


πŸŽ€ OPTIONS πŸŽ€

with the -z flag, NULL values are not crossed. what does that mean bestie? it means if a NULL value occurs in any input data layer, this combination is ignored β€” even if other data layers contain non-NULL data. so rude, but so efficient. πŸ™ˆ

in the example given below, use of the -z option would cause 3 categories to be generated instead of 5. three!! the glow-down of the century.

if the -z flag is not specified, then map layer combinations in which some values are NULL will be assigned a unique category value in the resulting output map. everyone gets a seat at the table, even the NULLs πŸ’œ

category values in the new output map layer will be the cross-product of the category values from these existing input map layers. slay.


🌟 EXAMPLE 🌟

for example, suppose that, using two raster map layers, the following combinations 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 like… don't @ me about the numbers, bestie 😭

🧚 SUPPORT FILES 🧚

the category file created for the output raster map layer describes the combinations of input map layer category values which generated each category. in the above example, 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 colors, no notes 🌈


πŸ‘€ SEE ALSO πŸ‘€

r.covar, r.stats

go read those too, they're in the same friend group 🫢


✍️ AUTHOR ✍️

Michael Shapiro, U.S. Army Construction Engineering Research Laboratory 🫑 absolute legend behavior.


πŸ’» SOURCE CODE πŸ’»

Available at: r.cross source code (history)

Accessed: Saturday Jan 17 05:40:45 2026

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index


and that's the whole page, bestie!! this was pulled from the GRASS GIS 8.4.2 Reference Manual, Β© 2003-2025 GRASS Development Team, running on GRASS 8.4.2 β€” mwah, go cross some rasters πŸ’…βœ¨

πŸ“¦ where this page comes from