Generate a grid with sequential numbers

From GRASS-Wiki
Revision as of 19:38, 17 September 2012 by Neteler (talk | contribs) (new)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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