Generate a grid with sequential numbers
Revision as of 03:45, 19 September 2012 by Mlennert
Q: How to generate a grid where the cell numbers are sequential?
A: You can useand for this:
# In a shell get rows and cols as environment variables eval `g.region -g` #(or just note the output of g.region -p and replace either $rows or $cols in the formulas below) # generate the a vertical grid (see image below) r.mapcalc "grid_seq = col() * $rows + row() - $rows" #or generate a horizontal grid r.mapcalc "grid_seq = row() * $cols + col() - $cols" #to visualise the category numbers in the grid d.mon x0 d.rast.num grid_seq
The resulting raster map of a vertical grid looks like this: