[GRASS-dev] Re: [GRASS-user] Get current location projection in a Python Script

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Wed Jul 21 10:39:14 EDT 2010


Nikos Alexandris wrote:
> > > > >>     rows = int(grass.region()['rows'])
> > > > >>     cols = int(grass.region()['cols'])

Glynn:
> > > > > In 7.0, these fields are already integers; r40555 should be
> > > > > backported.

Markus: 
> > > > AFAIK it has been backported some time ago.
> > > > http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/
> > > > lib/ python/core.py#L503

Glynn:
> > > Okay; change that to "I should 'svn update' the other branches more
> > > often", then ;)

Nikos:
> > This means it should be like:
> > 
> > rows = grass.region()['rows']
> > cols = grass.region()['cols']
> > 
> > Right?

Glynn Clements wrote: 
> Right; although you should store the result of grass.region() to avoid
> redundant g.region commands, i.e.:
> 
> 	rgn = grass.region()
> 	rows = rgn['rows']
> 	cols = rgn['cols']

Is  python's "int()" truncating or rounding up values? The question came to me 
while thinking of r.mapcalc's respective functions ( i.e. "int() != round()" )

Nikos


More information about the grass-dev mailing list