[GRASS-dev] get_proj() python function

Glynn Clements glynn at gclements.plus.com
Sun Jun 5 17:39:53 EDT 2011


Luca Delucchi wrote:

> Hi all, today I needed a python function for g.proj interface. I
> developed it and I think it could integrate in the main core.

For parsing, g.proj should be run with -j, e.g.:

def get_proj():
    return grass.parse_command("g.proj", flags='j')

The main reason why this hasn't been added to the library is that it's
barely worth the effort compared to including the code directly in the
script.

For a library function, one minor improvement would be to strip the
leading '+' from the key names, i.e.:

def get_proj():
    kv = grass.parse_command("g.proj", flags='j')
    return dict((k[1:], v) for k, v in kv.iteritems())

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


More information about the grass-dev mailing list