SequentialGrid: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(Blanked the page)
(Undo revision 16464 by Mlennert (talk))
Line 1: Line 1:
'''Q:''' How to generate a grid with sequential numbers?


'''A:'''
In a shell, first get number of rows and columns as environment variables:
eval `g.region -g`
(or just note the output of g.region -p and insert the relevant value at the appropriate place in the formulas below)
Then use the variable 'rows' or 'cols' as follows:
r.mapcalc "grid_seq = col() * $rows + row() - $rows"
gives you a "vertical" sequence.
r.mapcalc "grid_seq = row() * $cols + col() - $cols"
gives you a "horizontal" sequence.
[[Category:FAQ]]

Revision as of 13:10, 18 September 2012

Q: How to generate a grid with sequential numbers?

A:

In a shell, first get number of rows and columns as environment variables:

eval `g.region -g`

(or just note the output of g.region -p and insert the relevant value at the appropriate place in the formulas below)

Then use the variable 'rows' or 'cols' as follows:

r.mapcalc "grid_seq = col() * $rows + row() - $rows"

gives you a "vertical" sequence.

r.mapcalc "grid_seq = row() * $cols + col() - $cols"

gives you a "horizontal" sequence.