Generate a grid with sequential numbers: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(new)
(No difference)

Revision as of 19:38, 17 September 2012

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