[GRASS-user] Getting rows,cols of a region in a script

Hamish hamish_b at yahoo.com
Mon May 4 12:15:48 EDT 2009


Nikos:
> > I need the number of rows and columns to use with v.mkgrid. Currently I
> > use the following, rather long and complex command:
> > g.region -g | grep o | cut -d"=" -f2 | tr "\n" "," | cut -d"," -f1,2

Martin wrote:
> in Python
> 
> ret = grass.read_command('g.region', flags = 'g')
> reg = grass.parse_key_val(ret)
> print '%d,%d' % (int(reg['rows']), int(reg['cols']))


in the shell

eval `g.region -g`
echo $rows,$cols


:)
Hamish



      



More information about the grass-user mailing list