def raster_info(map): """Return information about a raster map (interface to `r.info -gre`). Example: >>> raster_info('elevation') # doctest: +ELLIPSIS {'creator': '"helena"', 'cols': '1500' ... 'south': 215000.0} :param str map: map name :return: parsed raster info """ def float_or_null(s): if s == 'NULL': return None else: return float(s) s = read_command('r.info', flags='gre', map=map) kv = parse_key_val(s) for k in ['min', 'max']: kv[k] = float_or_null(kv[k]) for k in ['north', 'south', 'east', 'west']: kv[k] = float(kv[k]) for k in ['nsres', 'ewres']: kv[k] = float_or_dms(kv[k]) return kv
def raster3d_info(map): """Return information about a raster3d map (interface to `r3.info`). Example: >>> mapcalc3d('volume = row() + col() + depth()') >>> raster3d_info('volume') # doctest: +ELLIPSIS {'vertical_units': '"units"', 'tbres': 1.0, ... 'south': 185000.0} >>> run_command('g.remove', flags='f', type='rast3d', pattern='volume') 0 :param str map: map name :return: parsed raster3d info """ def float_or_null(s): if s == 'NULL': return None else: return float(s) s = read_command('r3.info', flags='rg', map=map) kv = parse_key_val(s) for k in ['min', 'max']: kv[k] = float_or_null(kv[k]) for k in ['north', 'south', 'east', 'west', 'top', 'bottom']: kv[k] = float(kv[k]) for k in ['nsres', 'ewres', 'tbres']: kv[k] = float_or_dms(kv[k]) for k in ['rows', 'cols', 'depths']: kv[k] = int(kv[k]) for k in ['tilenumx', 'tilenumy', 'tilenumz']: kv[k] = int(kv[k]) for k in ['tiledimx', 'tiledimy', 'tiledimz']: kv[k] = int(kv[k]) return kv