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

Massimo Di Stefano massimodisasha at gmail.com
Mon Feb 8 06:30:56 EST 2010


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)

In [3]: dict_region_info
Out[3]: 
{'datatype': 'DCELL',
 'east': '609000',
 'ewres': '10',
 'max': '1846.743408',
 'min': '1061.064087',
 'north': '4928000',
 'nsres': '10',
 'south': '4914020',
 'timestamp': 'none',
 'title': ' elevation.10m',
 'units': '(none)',
 'vertical_datum': 'none',
 'west': '590010'}

In [4]: dict_region_info['east']
Out[4]: '609000'

the code maybe needs little adjustmens,  but it can give you an idea.




Il giorno 08/feb/2010, alle ore 11.36, António Rocha ha scritto:

> Thank you Markus. I suppose, for now, it's enough to give me a clue about managing LANDSAT images
> By the way, is there any specific command to retrieve a single information from metadata? I mean, r.info gives me a lot of information in a string.

maybe the grass-python bindings can help you ?

from grass, start 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)

In [3]: dict_region_info
Out[3]: 
{'datatype': 'DCELL',
 'east': '609000',
 'ewres': '10',
 'max': '1846.743408',
 'min': '1061.064087',
 'north': '4928000',
 'nsres': '10',
 'south': '4914020',
 'timestamp': 'none',
 'title': ' elevation.10m',
 'units': '(none)',
 'vertical_datum': 'none',
 'west': '590010'}

In [4]: dict_region_info['east']
Out[4]: '609000'

the code maybe needs little adjustmens,  but it can give you an idea.


> Best regards
> Antonio
>> 
>> Markus Neteler wrote:
>>> 2010/2/4 António Rocha <antonio.rocha at deimos.com.pt>:
>>> 
>>>> Greetings all
>>>> 
>>>> I'm doing a few scripts that requires accessing LANDSAT/or other satellite
>>>> images channel header information (e.g. Gain/Bias). Is it possible to acess
>>>> that information through a Script file? I mean, having a script that
>>>> processes what I want and in the meanwhile uses some channel header values?
>>>>    
>>> 
>>> See
>>> http://www.grassbook.org/examples_menu3rd.php
>>> -> CHAPTER 8: Scripts to bulk import LANDSAT-TM5/LANDSAT-TM7 scenes
>>>    from GLCF Maryland into GRASS
>>>    * glcf_landsat7_for_NC_SPM_WAKE_process.sh (reproject, spatial
>>> subset with GDAL)
>>>    * glcf_landsat5_for_NC_SPM_WAKE_import.sh (import into GRASS)
>>>    * glcf_landsat7_2000_for_NC_SPM_WAKE_import.sh (import into GRASS)
>>>    * glcf_landsat7_2002_for_NC_SPM_WAKE_import.sh (import into GRASS)
>>> 
>>> You can then use r.info to retrieve the metadata and use them for processing.
>>> 
>>> Hope this helps,
>>> Markus
>> 
>> 
> 
> 
> 
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 4847 (20100208) __________
> 
> The message was checked by ESET NOD32 Antivirus.
> 
> http://www.eset.com
> 
> 
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev



More information about the grass-dev mailing list