[GRASS-dev] wxGUI data catalog

Moritz Lennert mlennert at club.worldonline.be
Fri May 2 01:44:45 PDT 2014


On 01/05/14 19:18, Martin Landa wrote:
> Hi all,
>
> one of my students (Tereza, cc'ed) started to work on simple version
> of the data catalog implemented as a new tab in Layer Manager. This
> tool will allow to manage maps in the current location (remove, copy,
> or rename). Later could be added support for copying maps between
> different locations (including automated reprojection), preview of
> data and so on.
>
> Currently we are facing to the question whether to use in her code
> pyGRASS or just GRASS Python Scripting Library.  pyGRASS is not
> currently used in wxGUI at all (with only one exception - see
> gui_core/gselect.py [1]). There are some wxGUI components which should
> be rewritten using pygrass (those which already use ctypes), eg. wxGUI
> vector digitizer, but it's another story.
>
> So the question: do we start using pyGRASS in wxGUI more often even in
> the code where we don't need ctypes access and calling GRASS commands
> through GRASS Python Scripting Library is enough.
>
> The sample code from data catalog (copying maps):
>
> GRASS Python Scripting Library:
>
> cur_mapset = grass.gisenv()['MAPSET']
> grass.run_command('g.gisenv', set = 'MAPSET=%s' % dst_mapset)
> grass.run_command('g.copy', rast='%s@%s,%s' % (src_map, src_mapset, dst_name))
> grass.run_command('g.gisenv', set = 'MAPSET=%s' % cur_mapset)
>
> pyGRASS:
>
> cur_mapset = str(Mapset())
> Mapset(dst_mapset).current()
> g.copy(rast = '%s@%s,%s' % (src_map, src_mapset, dst_name)) # *
> Mapset(cur_mapset).current()
>
> * this could be replaced by something more fancy by modifying pyGRASS
>
> What is you opinion?
>
> Personally I incline to promote pyGRASS as interface for user scripts,
> but in wxGUI I still prefer to use GRASS Scripting Library to call
> GRASS commands on the background.

I don't know pyGRASS well enough to really judge. Could you explain your 
preference ?

More generally, I think that unless the two really fulfill two different 
purposes shouldn't we try to focus on one, instead of having the two ?

Moritz


More information about the grass-dev mailing list