cairodriver(1)

๐Ÿ’– cairodriver โ€” Cairo DISPLAY DRIVER ๐Ÿ’–

okay bestie, welcome to cairodriver, straight outta the GRASS GIS User's Manual โœจ this one is literally the Cairo display driver for bitmap or vector output, powered by the Cairo graphics library. it's giving art school but make it geospatial ๐ŸŽจ


โœจ DESCRIPTION โœจ

so here's the tea ๐Ÿซ– the Cairo driver generates PNG, BMP, PPM, PS, PDF or SVG images by running GRASS display commands, and it does it all with the Cairo graphics library. the image format? it's selected from the extension of the output file โ€” yes queen, the extension does the choosing ๐Ÿ’…

and the plot twist: the Cairo driver is used for GRASS display commands by default if available, otherwise the PNG driver gets the job instead. main character energy, truly ๐Ÿ‘‘


๐ŸŒธ USAGE ๐ŸŒธ

Environment variables

you can enable the Cairo driver by setting the GRASS_RENDER_IMMEDIATE variable, like:

export GRASS_RENDER_IMMEDIATE=cairo

and here's the whole cast of environment variables that affect how the Cairo driver operates ๐Ÿงš

  • GRASS_RENDER_WIDTH=xxx โ€” the width of the image map (default is 640). yes, tiny. yes, you can change it.
  • GRASS_RENDER_HEIGHT=yyy โ€” the height of the image map (default is 480).
  • GRASS_RENDER_BACKGROUNDCOLOR=RRGGBB โ€” specifies the background color to use in RGB notation (hex or R:G:B values). named colors are also supported, fancy. default is FFFFFF (white) ๐Ÿค
  • GRASS_RENDER_TRANSPARENT=[TRUE|FALSE] โ€” sets transparent background on (TRUE) or off (FALSE, default).
  • GRASS_RENDER_ANTIALIAS โ€” can be default, none, gray, or subpixel, corresponding to cairo_antialias_t.
  • GRASS_RENDER_FILE=filename โ€” the name and format of the resulting image file, default is map.png. the image format is determined from the file extension. supported bitmap formats:
    • .png โ€” Portable Network Graphics (PNG)
    • .bmp โ€” Windows Bitmap (BMP, 32-bpp) (these are not readable by some older viewers) ๐Ÿ’€
    • .ppm โ€” Portable Pixmap (PPM + PGM for alpha channel)

supported vector formats:

  • .pdf โ€” Portable Document Format (PDF)
  • .ps โ€” PostScript (PS)
  • .svg โ€” Scalable Vector Graphics (SVG)

(Note: some formats may not be available, depending on your platform and the Cairo library that GRASS was built with.)

  • GRASS_RENDER_FILE_READ โ€” if TRUE, the Cairo driver will initialize the image from the contents of GRASS_RENDER_FILE. (Note: this is only supported for bitmap formats)
  • GRASS_RENDER_FILE_MAPPED โ€” if TRUE, the Cairo driver will map GRASS_RENDER_FILE as its framebuffer, rather than using memory. (Note: this only works with BMP files.)
  • GRASS_RENDER_CAIRO_SCREEN โ€” defines Cairo screen
  • GRASS_RENDER_CAIRO_VISUAL โ€” defines Cairo visual

๐ŸŽ€ EXAMPLES ๐ŸŽ€

PNG Example

example: using the driver to generate a PNG file (bash-syntax):

export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE=nc_spm.png
export GRASS_RENDER_WIDTH=800
export GRASS_RENDER_HEIGHT=800
export GRASS_RENDER_FILE_READ=TRUE
g.region raster=elevation
d.rast map=elevation
d.vect map=streams width=1 color=blue fcolor=aqua type=area,line
d.vect map=roadsmajor width=2

PDF Examples

example: using the driver to generate a PDF vector file with a vector map (bash-syntax):

export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE=nc_spm.pdf
export GRASS_RENDER_WIDTH=800
export GRASS_RENDER_HEIGHT=800
g.region vector=roadsmajor
# activate vector font
d.font Vera
d.vect map=roadsmajor layer=1 display=shape attrcolumn=ROAD_NAME lcolor=0:90:255

example: using the driver to generate a PDF raster file with a raster map (bash-syntax):

export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE=nc_spm.pdf
export GRASS_RENDER_WIDTH=800
export GRASS_RENDER_HEIGHT=800
g.region raster=elevation
d.rast map=elevation

SVG Example

example: using the driver to generate a SVG vector file with a vector map (bash-syntax):

export GRASS_RENDER_IMMEDIATE=cairo
export GRASS_RENDER_FILE=vectormap.svg
g.region vector=roadsmajor
d.vect map=roadsmajor -c

๐Ÿ”ฅ NOTES ๐Ÿ”ฅ

ngl bestie, the driver is still in development ๐Ÿ™ˆ enable it by specifying --with-cairo when configuring GRASS. this requires a reasonably recent version of the Cairo libraries and a working pkg-config.

antialiasing is enabled by default for bitmap formats. there is currently no way of disabling this ๐Ÿ˜ญ so like, it's permanent. periodt.

the resolution of the output images is defined by current region extents. use g.region -p to get the number of rows and cols, and use the environment variables to set the image size. if you would like a larger image, multiply both rows and cols by the same whole number to preserve the aspect ratio โ€” math but make it cute ๐Ÿงฎโœจ

Cairo supports true vector format output whenever possible. however, if the selected format doesn't support a necessary feature, Cairo may fall back on rendering a bitmap representation of the image wrapped in the selected vector format. it's giving "fake it till you make it" ๐Ÿ’…


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

PNG driver, PS driver, HTML driver, variables

d.rast, d.vect, d.mon, d.erase, d.redraw


๐Ÿ’… AUTHOR ๐Ÿ’…

Lars Ahlzen <lars (at) ahlzen.com> and the GRASS Development Team.


โญ SOURCE CODE โญ

Available at: Cairo DISPLAY DRIVER source code (history)

Accessed: Saturday Jan 17 05:39:56 2026

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


and that's the whole vibe check ๐Ÿฆ‹ this was GRASS 8.4.2, ยฉ 2003-2025 GRASS Development Team, from the GRASS GIS 8.4.2 Reference Manual โ€” go make some gorgeous maps, bestie, you got this ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from