Hello all,
A very silly question...
How can I change my current working mapset during a single GRASS session,
while staying in the same location ? First, is it possible ? If not, what
prevents it (viz, what options are written where, that could reinitialized
with a script for example...)
Thanks in advance !
P
--
Soil & Water Laboratory
Dept. of Biological & Environmental Engineering
Cornell University
ITHACA, NY 14853
Tel: (607)255.2463
How can I change my current working mapset during a single GRASS session,
while staying in the same location ? First, is it possible ?
It's possible, but not officially supported (yet; this is a goal for
future versions of GRASS).
If not, what
prevents it (viz, what options are written where, that could reinitialized
with a script for example...)
Essentially, you just need to change the value of the MAPSET
parameter. Methods for doing this include:
1. Running the $GISBASE/etc/set_data program, and entering the new
settings.
2. Running "g.gisenv set=MAPSET=newmapset".
3. Editing the $GISRC file (i.e. ~/.grassrc5) manually.
Potential adverse side effects include:
1. The tcltkgrass interface won't recognise any changes; it reads the
parameters from $GISRC at start-up, and can't be made to re-read them.
The same is likely to apply to any other "persistent" programs such as
NVIZ.
2. Display monitors may retain data which relies upon the settings
remaining fixed; run "d.erase" prior to changing the settings.
3. Possibly others.
If you want to know exactly what a GRASS "session" is, look at the
scripts $GISBASE/etc/Init.sh and grass5 (typically
/usr/local/bin/grass5).
How can I change my current working mapset during a single GRASS
session, while staying in the same location ? First, is it possible ?
If not, what prevents it (viz, what options are written where, that
could reinitialized with a script for example...)
Short answer:
g.gisenv set="MAPSET=newmapset"
There's a few things to watch out for though:
1) changing mapsets this way doesn't clean out the .tmp directory,
wasting disk space.
2) The tcltkgrass menu system won't notice the change and shouldn't be
used.
3) NVIZ won't be aware if you change mapsets while it is running. Simple
solution is don't run NVIZ in the background and you won't have any
problems.
4) others?
The following is a little bash script I wrote called "g.nm" for changing
to a new mapset. I wrote it mostly to save a few key strokes, but it
empties the .tmp directory before changing too. It would be easy to add
a check to the script to see if the mapset (directory) exists before
changing; I've changed g.gisenv locally to do this so I haven't
bothered to do it here [see bug #1797]. http://intevation.de/rt/webrt?serial_num=1797
The "unset" part is to prevent mistakes if you had run "eval `g.gisenv`"
previously, but it currently doesn't work as planned (Bash experts?).
#!/bin/bash
if [ -z $GISBASE ] ; then
echo "You have to be in GRASS to use this."
exit
fi
if [ -z "$1" ]; then
echo "USAGE: g.nm newmapset"
echo " To change the current MAPSET to 'newmapset'"
exit
fi