Skip to content

r.out.png

Export a GRASS raster map as a non-georeferenced PNG image.

r.out.png [-tw] input=name output=name [compression=integer] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

r.out.png input=name output=name

grass.script.run_command("r.out.png", input, output, compression=6, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("r.out.png", input="name", output="name")

Parameters

input=name [required]
    Name of input raster map
output=name [required]
    Name for new PNG file (use '-' for stdout)
compression=integer
    Compression level of PNG file
    (0 = none, 1 = fastest, 9 = best)
    Allowed values: 0-9
    Default: 6
-t
    Make NULL cells transparent
-w
    Output world file
--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, required
    Name for new PNG file (use '-' for stdout)
    Used as: output, file, name
compression : int, optional
    Compression level of PNG file
    (0 = none, 1 = fastest, 9 = best)
    Allowed values: 0-9
    Default: 6
flags : str, optional
    Allowed values: t, w
    t
        Make NULL cells transparent
    w
        Output world file
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.png exports a GRASS raster map in non-georeferenced Portable Network Graphics (PNG) image format, respecting the current region resolution and bounds.

Optionally the user can choose to export a World File (.wld) to provide basic georeferencing support. When used with the transparency flag this can create images useful for KML, TMS, or WMS overlays. (e.g. for use in Google Earth or as OpenLayers tiles) If output is redirected to stdout, the world file will be called png_map.wld.

EXAMPLE

The example is based on the North Carolina sample data.

Export of the soil map to PNG format with world file:

g.region raster=soils_Kfactor -p
# export PNG file with additional world file
r.out.png input=soils_Kfactor output=soils_Kfactor -w
# verify
gdalinfo soils_Kfactor.png

SEE ALSO

r.out.gdal, r.out.ppm, r.out.ascii, r.import

AUTHORS

Alex Shevlakov
Hamish Bowman

SOURCE CODE

Available at: r.out.png source code (history)
Latest change: Tuesday May 20 11:33:36 2025 in commit 8efb37c