Pietro Zambelli wrote:

> > > > > Why the ctypes version return 'PERMANENT' instead of 'user1'?

Glynn Clements wrote:

> > > > The $GISRC file is read the first time that an environment lookup is
> > > > made. There is no way to force it to be re-read.

Nikos Alexandris wrote:

> > > This means that I can't use instructions like
> > [...]
> > > in a function (pasted below) which I call from within a "for" loop to go
> > > through Mapsets that potentially contain raster maps named differently?

Glynn Clements wrote:

> > You can modify the current process' environment with G_setenv().

Pietro Zambelli wrote:

> Or use the method
> current() => to set the mapset as current

Perfect, shorter!

Previously:

        mapsets = grass.mapsets()
   for scene_id in mapsets:

                ### some condition to catch "scene_id"s of interest here! ###

                # enter in (a) Mapset of interest
                grass.run_command("g.mapset",
                                                         mapset = scene_id,
                           verbose = False
                                )
                print "Operating inside Scene-Mapset <%s>\n" % scene_id

Now:

        mapsets = grass.mapsets()
   for scene_id in mapsets:

                ### some condition to catch "scene_id"s of interest here! ###

                # enter in (a) Mapset of interest       
                Mapset(scene_id).current()
                print "\nOperating inside Scene-Mapset <%s>\n" % scene_id


This way I've seen (harmless) WARNINGS about matching same raster maps names 
in other Mapsets.  To be sure that only the "current" and the PERMANENT 
Mapsets are accessed, I added the following

        # grant access to current and PERMANENT Mapsets only
   grass.run_command("g.mapsets",
                                                 operation = 'set',
                                                 mapset= '.,PERMANENT',
                     verbose = False
                                                 )

Thanks, that helped a lot.

Nikos
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to