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 map
  • output=name β€” Name for new PPM file (use '-' for stdout)
    • Default: <rasterfilename>.ppm

πŸ’– 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