[GRASS-dev] GRASS Scripts access to channel headers info

Glynn Clements glynn at gclements.plus.com
Mon Feb 8 16:37:40 EST 2010


Massimo Di Stefano wrote:

> Hi, maybe the grass-python bindings can help you ?
> 
> from grass, starting python :
> 
> In [1]: import grass.script as grass
> 
> In [2]: dict_region_info = dict(x.split('=', 1) for x in
> grass.read_command('r.info', flags = 'rstgudmp', map =
> 'elevation.10m').strip().replace('"','').replace('(','').replace(')','').split('\n')
> if '=' in x)

raster_info() already does this; it also converts the bounds and range
to numbers:

> grass.raster_info('elevation.dem')
{'north': 4928000.0,
 'timestamp': '"none"',
 'min': 1066.0,
 'datatype': 'CELL',
 'max': 1840.0,
 'ewres': 30.0,
 'vertical_datum': '(none)',
 'west': 590010.0,
 'units': '(none)',
 'title': 'DEM (7.5 minute) (elevation)',
 'east': 609000.0,
 'nsres': 30.0,
 'south': 4914020.0}

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list