r.out.ppm
Converts a GRASS raster map to a PPM image file.
r.out.ppm [-gh] input=name [output=name] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r.out.ppm input=name
grass.script.run_command("r.out.ppm", input, output="<rasterfilename>.ppm", flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("r.out.ppm", input="name")
Parameters
input=name [required]
Name of input raster map
output=name
Name for new PPM file (use '-' for stdout)
Default: <rasterfilename>.ppm
-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
--qq
Very quiet module output
--ui
Force launching GUI dialog
input : str, required
Name of input raster map
Used as: input, raster, name
output : str, optional
Name for new PPM file (use '-' for stdout)
Used as: output, file, name
Default: <rasterfilename>.ppm
flags : str, optional
Allowed values: g, h
g
Output greyscale instead of color
h
Suppress printing of PPM header
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
r.out.ppm converts a GRASS raster map into a PPM image at the pixel resolution of the CURRENTLY DEFINED REGION. To get the resolution and region settings of the raster map, run:
g.region -p raster=[mapname]
before running r.out.ppm.
By default the PPM file created is 24-bit color, rawbits storage. You can use the -g flag to force r.out.ppm to output 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 if ew_res
and ns_res
differ, the aspect ratio of the resulting image will be off.
NOTES
A few ppm file comments are written: the name of the GRASS raster map,
resolution, etc. Although these are perfectly legal, I've found one PD
image utility that chokes on them, so if you need a commentless PPM
file, use 'out=- > outfile.ppm
'. (When sending output to stdout, no
comments are written.)
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. Alternatively, you can use the pnmtopng program from netpbm to do this:
r.out.ppm raster
pnmtopng -transparent white raster.ppm > raster.png
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: Friday Feb 07 19:16:09 2025 in commit a82a39f