GRASS GIS addon to create smoothed legend image

I just uploaded a small addon for GRASS GIS, r.out.legend, with which you can quickly create a smoothed legend image for floating point raster maps (continuous values as opposed to categories).

You just select the raster layer, the dimensions and resolution required and the name of the output image. Other options are to change the font and font size and the image type (PNG, BMP, PDF and SVG).

r_out_legend_4
Example of an output of the r.out.legend addon

The script is a wrapper of the functions d.mon and d.legend. For detailed explanations of the different options, see the manual pages of these two functions. For a more interactive way to generate maps, check out ps.map.

I originally wrote the script to create smooth legend for use in the map composer of QGIS, because it is no option (yet) to create a smooth legend from within the map composer. There are, I should add, some other nice solutions, see for example this Q & A at gis.stackexchange.

Below an example how to use the addon. In this example I have set the background to grey. Note that the default is a transparent background.

r.out.legend raster=elevation \
file=r_out_legend_2.png filetype=png \
dimensions=300,20 labelnum=3 fontsize=10 unit="px" \
font=comic bgcolor=grey

r_out_legend_2

You can also, just like in d.legend, add a histogram distribution, which will be placed left of the bar (if vertical) or above (if horizontal).

r.out.legend -d raster=elevation \
file=r_out_legend_5.png filetype=png \
dimensions=300,20 labelnum=3 fontsize=10 unit="px" \
font=comic

r_out_legend_5

 

For other examples, see the manual page.

And with just a little bit of post processing you can create slightly more fancy (more colour full) histograms. The one below was done in GIMP in just a few simple steps. You can of course do the same in Inkscape, just make sure to select the option to export as svg. I’ll leave it up to you to figure out how to do this😉

r_out_legend_5

 

 

One thought on “GRASS GIS addon to create smoothed legend image

  1. Pingback: GRASS GIS addon to create smoothed legend image – GeoNe.ws

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s