[GRASS-user] generate a grid with sequential numbers

Moritz Lennert mlennert at club.worldonline.be
Mon Sep 17 08:58:09 PDT 2012


On 17/09/12 17:46, Moritz Lennert wrote:
> On 17/09/12 16:05, Janet Choate wrote:
>> Hi all,
>> does anyone know how to generate a grid where the numbers are sequential?
>> i have used r.random.cells to create a grid, but grids are numbered,
>> well, randomly.
>
> Maybe r.mapcalc with a combination of the row() and col() functions ?
> Depending on the number of cells you have you can do something like
> this: row()*10000+col(). This will give you an ordered sequence, but
> numbers from one line to the next will have a gap. If you need perfectly
> sequenced numbers, I imagine it's possibly to find a formula that gives
> you that...

Try

r.mapcalc sequential_grid=(row()*NumberOfColumns+col())-NumberOfColumns

You can get the number of columns in your region with g.region -p ("cols").

Moritz


More information about the grass-user mailing list