[GRASS-dev] get_proj() python function

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.
In attachment you can find the diff

--
regards
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

(attachments)

get_proj.diff (1.19 KB)

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@gclements.plus.com>

2011/6/5 Glynn Clements <glynn@gclements.plus.com>:

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.:

You are right but with -p the output contain more values like datum
and units... for this I used -p flag

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

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

On Mon, Jun 6, 2011 at 12:09 PM, Luca Delucchi <lucadeluge@gmail.com> wrote:

2011/6/5 Glynn Clements <glynn@gclements.plus.com>:

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.:

You are right but with -p the output contain more values like datum
and units... for this I used -p flag

There are some differences, though:

Gauss-Boaga Fuso 1 example:

GRASS 6.4.2svn (patGB1):~ > g.proj -p
-PROJ_INFO-------------------------------------------------
name : Transverse Mercator
datum : rome40
datumparams: towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68
proj : tmerc
ellps : international
a : 6378388.0000000000
es : 0.0067226700
f : 297.0000000000
lat_0 : 0.0000000000
lon_0 : 9.0
k_0 : 0.9996000000
x_0 : 1500000.0000000000
-PROJ_UNITS------------------------------------------------
unit : Meter
units : Meters
meters : 1

GRASS 6.4.2svn (patGB1):~ > g.proj -j
+proj=tmerc
+lat_0=0.0000000000
+lon_0=9.0
+k_0=0.9996000000
+x_0=1500000.0000000000
+a=6378388
+rf=297
+no_defs
+towgs84=-104.1,-49.1,-9.9,0.971,-2.917,0.714,-11.68
+to_meter=1

The question is if the -p output is "over"described or not.

Markus

Hi,

2011/6/7 Markus Neteler <neteler@osgeo.org>:

The question is if the -p output is "over"described or not.

not sure, if not, we could add `-g` flag to print proj/units info in
shell script style...

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

2011/6/7 Martin Landa <landa.martin@gmail.com>:

not sure, if not, we could add `-g` flag to print proj/units info in
shell script style...

+1 for `-g` flag

Martin

--
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Hi,

2011/6/7 Luca Delucchi <lucadeluge@gmail.com>:

not sure, if not, we could add `-g` flag to print proj/units info in
shell script style...

+1 for `-g` flag

done in r46850

Martin

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa