Generate a grid with sequential numbers

From GRASS-Wiki
Revision as of 12:38, 17 September 2012 by Neteler (talk | contribs) (new)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Q: How to generate a grid where the cell numbers are sequential?

A: You can use g.region and r.mapcalc for this:

# get rows and cols as environment variables
eval `g.region -g`

# generate the grid
r.mapcalc "grid_seq = col() * $rows + row() + $cols - ($rows + $cols)"

d.mon x0
d.rast.num grid_seq

The resulting raster map looks like this:

Sequentially numbered raster grid