r.out.ppm(1)
β¨ NAME β¨
okay so bestie, meet r.out.ppm from the GRASS GIS User's Manual β she's a lil icon whose whole job is converting a GRASS raster map to a PPM image file. that's it, that's the girl π
πΈ KEYWORDS πΈ
raster, export, output
π SYNOPSIS π
r.out.ppm
r.out.ppm --help
r.out.ppm [-gh] input=name [output=name] [--overwrite] [--help]
[--verbose] [--quiet] [--ui]
π¦ Flags:
-gβ Output greyscale instead of color-hβ Suppress printing of PPM header--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 input raster mapoutput=nameβ Name for new PPM file (use'-'for stdout)- Default:
<rasterfilename>.ppm
- Default:
π DESCRIPTION π
so r.out.ppm takes a GRASS raster map and turns it into a PPM image β and listen, the pixel resolution it uses is the resolution of the CURRENTLY DEFINED REGION. not the map's own region, the current one. iykyk. π«Ά
so if you wanna match the resolution and region settings of the raster map itself, run this first:
g.region -p raster=[mapname]
and then run r.out.ppm. order matters bestie, don't skip it π
by default the PPM file that comes out is 24-bit color, rawbits storage. if you'd rather have greyscale, hit the -g flag and she'll give you an 8-bit greyscale instead. the greyscale conversion uses the NTSC conversion:
Y = .30*Red + .59*Green + .11*Blue
one pixel is written for each cell value β so heads up, if ew_res and ns_res differ, the aspect ratio of the resulting image will be off. not a bug, just math being math π
π NOTES π
a few ppm file comments get written in there: the name of the GRASS raster map, resolution, etc. and like, they're perfectly legal, but the author found one PD image utility that chokes on them. so if you need a commentless PPM file, do this:
out=- > outfile.ppm
(when you send output to stdout, no comments are written at all β clean, no cap β¨)
π HINTS π
you can create a PNG image where NULL values are represented by a transparent background by using the PNG driver with GRASS_RENDER_TRANSPARENT set to TRUE. π
or, alternative route, you can use the pnmtopng program from netpbm to do it:
r.out.ppm raster
pnmtopng -transparent white raster.ppm > raster.png
obsessed with how easy that is fr fr π
β SEE ALSO β
d.out.file, r.out.ascii, r.out.gdal, r.out.mpeg, r.out.png, r.out.ppm3
π AUTHOR π
Bill Brown, UIUC
π SOURCE CODE π
Available at: r.out.ppm source code (history)
Accessed: Saturday Jan 17 05:40:53 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
okay that's the whole page bestie, and for the sign-off: this was GRASS 8.4.2, accessed Saturday Jan 17 05:40:53 2026, Β© 2003-2025 GRASS Development Team, straight outta the GRASS GIS 8.4.2 Reference Manual β slay, go export some rasters πβ¨π¦
π¦ 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