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

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Mon May 4 10:52:44 EDT 2009


On Mon, 2009-05-04 at 16:28 +0200, Martin Landa wrote:
> 2009/5/4 Nikos Alexandris <nikos.alexandris at felis.uni-freiburg.de>:
> > 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
> 
> 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']))
> 
> Martin

Thanks for that one :-)
Nikos



More information about the grass-user mailing list