GRASS logo

Note: A new GRASS GIS stable version has been released: GRASS GIS 7. Go directly to the new manual page here


PNG driver - driver to create PNG and PPM images.


The PNG driver generates PNG and PPM images from GRASS display commands. Per default PNG files are written with this driver. It is started as 'pseudo' monitor (image file instead) and when stopped, all output from previously used display commands are written to the PNG image file.


Environment variables

Several environment variables affect the operation of the PNG driver.


  1. Define driver settings (here: bash shell syntax)
  2. Start up the driver
    d.mon start=PNG
  3. Display raster map and vector polygons
    d.rast somerastermap
    d.vect somevectormap color=red
  4. Stop the driver subsequently. This will write a file named map.png to be created in your current directory:
    d.mon stop=PNG


The PNG driver uses the libpng (see the libpng home page) and zlib (see the zlib home page), all which needs to be installed for the PNG driver to work (it's worth it).

The resolution of the PNG raster map is defined by the map extents. Use g.region -p to get the number of rows and cols and use the environment variables to set the PNG size. If you would like a larger image, multiply both rows and cols by the same whole number to preserve the aspect ratio.

Further PNG file processing (e.g. quantization to 1 bit for monochrome images) can be done with 'pnmquant' of the netpbm tools.


Display drivers
HTMLMAP driver, PostScript driver, XDRIVER
d.frame, d.mon, d.rast, d.vect


Original version: Per Henrik Johansen <phj (at)> NORGIT AS
Rewritten by: Glynn Clements, 2003

Last changed: $Date: 2016-08-17 23:50:38 -0700 (Wed, 17 Aug 2016) $

Main index - pngdriver index - Full index

© 2003-2016 GRASS Development Team