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

Martin Landa landa.martin at gmail.com
Mon May 4 10:28:13 EDT 2009


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

-- 
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa


More information about the grass-user mailing list