r.recode(1grass)
π r.recode β the GRASS manual, but make it cute π
okay bestie, pull up a chair because we're doing r.recode(1grass) from the GRASS User's Manual and honestly? it's giving glow-up for your raster maps. no cap. β¨
πΈ NAME πΈ
r.recode β Recodes categorical raster maps. that's it, that's the whole job, and she does it flawlessly. π
π KEYWORDS π
raster, recode categories, reclassification
β¨ SYNOPSIS β¨
r.recode
r.recode --help
r.recode [-ad] input=name output=name rules=name [title=string]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π Flags
-aβ Align the current region to the input raster map-dβ Force output to βdoubleβ raster map type (DCELL). highkey a precision moment--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=name[required]β Name of raster map to be recodedoutput=name[required]β Name for output raster maprules=name[required]β File containing recode rules.'-'for standard inputtitle=stringβ Title for output raster map
π DESCRIPTION π
so r.recode creates an output raster map by recoding an input raster map based on your recode rules. and if you want a title on that output raster map, you may (optionally, no pressure bestie) specify one yourself. π«Ά
the recode rules can be read from standard input β like from the keyboard, redirected from a file, or piped through another program β and you do that by entering rules=-. yes, literally just a lil dash. iconic.
Rules are defined in one of these formats:
old_low:old_high:new_low:new_high
old_low:old_high:new_val (i.e. new_high == new_low)
*:old_val:new_val (interval [inf, old_val])
old_val:*:new_val (interval [old_val, inf])
r.recode is loosely based on r.reclass and uses the GRASS Reclass Library to convert the rasters. it has routines for converting to every possible combination of raster (eg. CELL to DCELL, DCELL to FCELL, etc). standard floating point raster precision is float (FCELL), and with -d, double precision (DCELL) will be written. the range of options?? obsessed. π
There are four basic routines that it accepts:
- old-low to old-high is reclassed to new-low to new high , where the user provides all four values. The program figures on the fly what type of raster should be created.
- old-low to old-high is reclassed to a single new value. Anything outside the range is null.
*to old-high will reclass everything less than old-high to a single new value.- old-low to
*will reclass everything greater than old-low to a single new value.
These four sets of arguments can be given on the command line, or piped via stdin or a file. More than one set of arguments is accepted. she's flexible like that. π
π EXAMPLES π
π Map type conversion
To simply convert a raster between formats (eg. int to float) the user would use the first argument. For example
10:1500:0.1:15.0
would convert an input raster map with range between 10 and 1500 to a float raster raster with range between 0.1 and 15.0.
π§ Value replacement
r.recode can be used to replace existing cell values by others. The formatting is as described above. In following example the values 1, 2 and 3 are replaced by 1.1, 7.5 resp. 0.4:
r.recode input=oldmap output=newmap rules=- << EOF
1:1:1.1:1.1
2:2:7.5:7.5
3:3:0.4:0.4
EOF
π SEE ALSO π
r.reclass
π AUTHOR π
CERL
β SOURCE CODE β
Available at: r.recode 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
okay that's the whole page bestie, go recode something gorgeous π β¨
and that's a wrap, babes π this was GRASS 8.5.0, Β© 2003-2026 GRASS Development Team, straight outta the GRASS 8.5.0 Reference Manual β main character manual energy only, periodt. π¦
π¦ 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