r.out.ppm(1grass)

✨ r.out.ppm ✨

okay bestie, gather round, because this is the GRASS User's Manual page for r.out.ppm and it's literally the glow-up station for your raster maps πŸ’… turning them into PPM image files so they can go be cute somewhere else.

🌸 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 (the lil switches, iykyk)

  • -g β€” bestie this is greyscale mode, no color allowed, we're going monochrome ✨ outputs greyscale instead of color
  • -h β€” suppresses printing of the PPM header. shhh. no header. πŸ™ˆ
  • --overwrite β€” lets your output files overwrite existing files, so yes it will absolutely just eat the old one, that's on you 🫢
  • --help β€” prints the usage summary, the classic "wait what do I do" button
  • --verbose β€” verbose module output, it will simply tell you everything
  • --quiet β€” quiet module output, it will tell you not a single thing 🀫
  • --ui β€” forces the GUI dialog to launch, main character energy for your mouse

πŸ“ Parameters

  • input=name [required] β€” the name of the input raster map. mandatory. non-negotiable. no input no output periodt
  • output=name β€” the name for the new PPM file (and yes, you can use '-' for stdout) Default: <rasterfilename>.ppm

πŸ’– DESCRIPTION πŸ’–

So r.out.ppm converts a GRASS raster map into a PPM image at the pixel resolution of the CURRENTLY DEFINED REGION. like, the region you've got set right now, not the map's own vibe. so if you want 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.

By default the PPM file it creates is 24-bit color, rawbits storage. gorgeous. iconic. but you can use the -g flag to force r.out.ppm to output an 8-bit greyscale instead. and the greyscale conversion uses the NTSC conversion:

Y = .30*Red + .59*Green + .11*Blue

One pixel is written for each cell value, so if ew_res and ns_res differ, the aspect ratio of the resulting image will be off. like it'll be stretched. not a bug, just math being math 😭


πŸ“ NOTES πŸ“

A few ppm file comments are written: the name of the GRASS raster map, resolution, etc. and like, these are perfectly legal, truly nothing wrong with them, but the author has found one PD image utility that chokes on them πŸ’€ so if you need a commentless PPM file, use 'out=- > outfile.ppm'. and when you're sending output to stdout, no comments are written. so there. clean output, no drama.

lowkey important: comments out = stdout only. that's the trick.

πŸ”₯ HINTS πŸ”₯

You can create a PNG image with NULL values represented by a transparent background by using the PNG driver with GRASS_RENDER_TRANSPARENT set to TRUE. that's one route 🧚

Alternatively, you can use the pnmtopng program from netpbm to do this:

r.out.ppm raster
pnmtopng -transparent white raster.ppm > raster.png

two lines, transparent background, slay 🌈


πŸ‘‘ 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)

Latest change: Wednesday Jul 02 11:43:06 2025 in commit: 78b88bc34582428809d4a98ae07e2500953f7333

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


and that's the whole page bestie 🫢 thanks for reading this far, you're literally the moment. this was r.out.ppm(1grass) from the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, running on GRASS 8.5.0. go export something cute and take care of yourself πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from