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

Continue reading “GRASS GIS addon to create smoothed legend image”

Compiling the gdal-grass plugin for GRASS 7

The idea of the GDAL-GRASS plugin is to directly access GRASS raster and vector data from outside. Any GDAL enabled software (QGIS, R, …) can read and write through the plugin from the GRASS database. The different steps are explained on the grass wiki. Mostly as a note to self, I am copying those steps below (for GRASS 7), with some small changes that made this work for me. Continue reading “Compiling the gdal-grass plugin for GRASS 7”

The r.series function applied to a range of values

One of the fundamental functions in GRASS GIS is the r.series function. It makes each output cell value a function of the values assigned to the corresponding cells in the input raster map layers. I use it very often in my analyses, but I only recently ‘discovered’ this option to ignore values outside an user-defined range. Continue reading “The r.series function applied to a range of values”

PyGRASS equivalent of piping results from one function to another

When using GRASS commands on the command line, one very neat little trick is to ‘pipe’ results from one function directly to another. An example I used in an earlier post is:

r.category My_map | r.category My_map rules=-

So, how does that works in python using pygrass?
Continue reading “PyGRASS equivalent of piping results from one function to another”

Counting number of layers returned by g.list in GRASS GIS

I am running a script that is producing a very large number of layers. As it takes a while, I wanted to find out how many layers were already created using the command line. Trivial thing perhaps, but I wasn’t really sure how to do it. After a bit of search, one way I found uses the versatile awk command line tool. Continue reading “Counting number of layers returned by g.list in GRASS GIS”

GRASS GIS categorical maps and legends

Did you ever add a legend to your categorical raster map in GRASS GIS that displayed many more categories than your map actually has? It can happen if that map was ‘cut out’ from a larger region using r.mapcalc. For example, if I have a vegetation map of eastern Africa, and I need one for Rwanda only. I would do something like: Continue reading “GRASS GIS categorical maps and legends”

Another stab at creating a Tanaka-style contour map

In a recent post Anita Graser (aka underdark) showed how to create illuminated or Tanaka contours in QGIS using various functions available in the toolbox and some custom functions.

Here I want to explore a slightly different way to achieve the same, using GRASS GIS to compute the azimuth, brightness and line width. I’ll use the command line, but you can do the same using the menu in GRASS, or the corresponding GRASS functions in the QGIS processing toolbox.

Continue reading “Another stab at creating a Tanaka-style contour map”