[GRASS-user] some issues with python scripts

Martin Landa landa.martin at gmail.com
Mon Jan 17 08:12:17 EST 2011


2011/1/16 Carlos Grohmann <carlos.grohmann at gmail.com>:
> 2 - dealing with maps names. if I use find_file, I end up with the
> full name of the map (that is, map name plus mapset) in the
> dictionary. The wx interface created by g.parser includes the mapset
> in the map name, and all that goes as a string to find_file:
>
>>>> import grass.script as grass
>
> # this is what should happen
>>>> elevmap = 'cass'
>>>> find_elev = grass.find_file(elevmap, element = 'cell')
>>>> find_elev
> {'fullname': 'cass at brasil', 'mapset': 'brasil', 'name': 'cass',
> 'file': '/home/guano/grassdata/amsul_wgs84/brasil/cell/cass'}
>
> # this is what actually happens when using the wx interface
>>>> elevmap = 'cass at brasil'
>>>> find_elev = grass.find_file(elevmap, element = 'cell')
>>>> find_elev
> {'fullname': 'cass at brasil', 'mapset': 'brasil', 'name': 'cass at brasil',
> 'file': '/home/guano/grassdata/amsul_wgs84/brasil/cell/cass'}
>>>>

this corresponds with behaviour of g.findfile

GRASS 7.0.svn (nc_spm_08):~/src/grass_trunk > g.findfile element=cell file=dummy
name='dummy'
mapset='landa'
fullname='dummy at landa'
file='/home/martin/grassdata/nc_spm_08/landa/cell/dummy'
GRASS 7.0.svn (nc_spm_08):~/src/grass_trunk > g.findfile element=cell
file=dummy at landa
name='dummy at landa'
mapset='landa'
fullname='dummy at landa'
file='/home/martin/grassdata/nc_spm_08/landa/cell/dummy'

> 3 - temp files.
> In my bash scripts I used temp files. I found out that using
> g.tempfile() gives me a filename with a full path, which cannot be
> used in r.mapcalc, for instance.
> So I just used normal files that I delete in the end of the script. Is
> there a better way?

Sample code?

Martin

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


More information about the grass-user mailing list