Hi Rich - Here's a generic version of what I did (I'm not the best programmer, 
but this worked):

# this is necessary because the environments change in this script
GISDBASE="D:/GRASSDATA/"   # use your info!
LOCATION_NAME_1="latlon"   # use your info!
LOCATION_NAME_2="UTM_23"   # use your info!
MAPSET_1="user_latlon_maps"   # use your info!
MAPSET_2="user_UTM23_maps"   # use your info!
HISTFILE_1="$GISDBASE/$LOCATION_NAME_1/$MAPSET_1"/.bash_history
HISTFILE_2="$GISDBASE/$LOCATION_NAME_2/$MAPSET_2"/.bash_history
history -w
history -r "$HISTFILE_1”
# make sure mapsets in the location are available to change into (this is a 
user control)
# you can change mapsets within the location easily but changing locations 
requires
# resetting the history file
g.mapsets mapset=$VMAP_MAPSET,$ MAPSET_1,$SUB_MAPSET,$CLIM_MAPSET operation=set
                # set your mapset (in the current location)
g.mapset mapset=$MAPSET_1 location=$LOCATION_NAME_1 dbase=$GISDBASE
# set your region!
g.region -a vector=SomeMap@$MAPSET_1
                # do your GRASS thing
…
                # now change your location and mapset
history -w
history -r "$HISTFILE_2”
                # if you need more than one mapset in this location, make them 
available to the user:
g.mapsets mapset=$MAPSET_2,$MAPSET_X,$MAPSET_Y operation=set
g.mapset mapset=$MAPSET_2 location=$LOCATION_NAME_2 dbase=$GISDBASE
# set your region!
g.region -a vector=SomeMap@$MAPSET_2
                # do your GRASS thing
…
# reset the mapset and counters
history -w
history -r "$HISTFILE_1”
g.mapset mapset=$MAPSET_1 location=$LOCATION_NAME_1 dbase=$GISDBASE
# reset your region!
g.region -a vector=SomeMap@$MAPSET_1



I hope this helps you

[😊]

Chris


Chris Bartolomei P.E.
[email protected]
________________________________
From: grass-user <[email protected]> on behalf of Markus Metz 
<[email protected]>
Sent: Wednesday, November 1, 2017 12:38:07 AM
To: Rich Shepard
Cc: [email protected]
Subject: Re: [GRASS-user] Switching locations on-the-fly



On Wed, Nov 1, 2017 at 12:21 AM, Rich Shepard 
<[email protected]<mailto:[email protected]>> wrote:
>
> On Tue, 31 Oct 2017, Bartolomei.Chris wrote:
>
>> are you using the gui or in a bash shell?
>
>
> Chris,
>
>   Both. I'll use the GUI when reprojecting because it's less typing than the
> whole path name to the source. Most often I use the shell (bash).
>
>> In the gui, go to Settings, GRASS working environment, Change location and 
>> mapset
>
>
>   Good to know. I've not explored all the GUI menus.
>
>> That will change it all on the fly. You can do this in a batch script as
>> well but it's a little tricky - your .bash_history changes with changed
>> locations and you need to reset your GISDBASE, MAPSET, and LOCATION
>> internal GRASS variables, etc. Let me know if you want those steps and
>> I'll dig them out of an old script I have.
>
>
>   When you can, please share them with me.

You can use g.mapset to switch locations (also GRASS databases) on the fly. 
With g.mapset, the .bash_history of the initial location will be used to record 
command history.

Markus M
>
> Much appreciated,
>
> Rich
> _______________________________________________
> grass-user mailing list
> [email protected]<mailto:[email protected]>
> https://lists.osgeo.org/mailman/listinfo/grass-user<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.osgeo.org_mailman_listinfo_grass-2Duser&d=DwMFaQ&c=DsZY2bea7iNIzyp-7sZ0t0F2UfNQZUfZhEPCv_2wBI0&r=O31ltou6ygJL2Y01kQyNJJD2kiILIsbyz2V0Hn4lFUY&m=pAguFuiUBov1tfBBuR6-VEecI77VqdSzgldIb7apFU4&s=1Q7YttQ4IjrgaQNBM3VUI0QGWE3Lk9xHGGTu63-LyJE&e=>


________________________________

The information contained in this email message is intended only for the use of 
the individual(s) to whom it is addressed and may contain information that is 
privileged and sensitive. If you are not the intended recipient, or otherwise 
have received this communication in error, please notify the sender immediately 
by email at the above referenced address and note that any further 
dissemination, distribution or copying of this communication is strictly 
prohibited.

The U.S. Export Control Laws regulate the export and re-export of technology 
originating in the United States. This includes the electronic transmission of 
information and software to foreign countries and to certain foreign nationals. 
Recipient agrees to abide by these laws and their regulations -- including the 
U.S. Department of Commerce Export Administration Regulations and the U.S. 
Department of State International Traffic in Arms Regulations -- and not to 
transfer, by electronic transmission or otherwise, any content derived from 
this email to either a foreign national or a foreign destination in violation 
of such laws.
_______________________________________________
grass-user mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to