[GRASSLIST:1153] Re: Changing mapsets
Hamish
hamish_nospam at yahoo.com
Tue Sep 9 20:41:13 EDT 2003
> 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
unset MAPSET
export MAPSET
$GISBASE/etc/clean_temp
g.gisenv set=MAPSET=$1 && \
echo "=> New MAPSET: $1"
regards,
Hamish
More information about the grass-user
mailing list