[GRASS-user] Switching locations on-the-fly

   I need to import a lot of data each having one of several projections. It
is quicker for me to create a new location for each one, import it, then
re-project it to the base location and a layer-specific mapset. This
involves invoking grass, creating a new location, importing the .shp or
.gdb, shutting down grass, restarting grass in the base location,
re-projecting the new layer, then removing the (temporary) importing
location.

   Is there a way to switch locations within a running grass instance,
equivalent to creating/switching mapsets within a location?

Rich

are you using the gui or in a bash shell?

In the gui, go to Settings, GRASS working environment, Change location and mapset

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.

Chris Bartolomei P.E.
bartolomei.chris@ensco.com
________________________________
From: grass-user <grass-user-bounces@lists.osgeo.org> on behalf of Rich Shepard <rshepard@appl-ecosys.com>
Sent: Tuesday, October 31, 2017 4:00:48 PM
To: grass-user@lists.osgeo.org
Subject: [GRASS-user] Switching locations on-the-fly

   I need to import a lot of data each having one of several projections. It
is quicker for me to create a new location for each one, import it, then
re-project it to the base location and a layer-specific mapset. This
involves invoking grass, creating a new location, importing the .shp or
.gdb, shutting down grass, restarting grass in the base location,
re-projecting the new layer, then removing the (temporary) importing
location.

   Is there a way to switch locations within a running grass instance,
equivalent to creating/switching mapsets within a location?

Rich

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.osgeo.org_mailman_listinfo_grass-2Duser&d=DwIGaQ&c=DsZY2bea7iNIzyp-7sZ0t0F2UfNQZUfZhEPCv_2wBI0&r=O31ltou6ygJL2Y01kQyNJJD2kiILIsbyz2V0Hn4lFUY&m=-DpjZEMiCvhV9YNdBPtwe5hKWMSur_IQdmTdKBWPf74&s=Qrgm5-2UvnsH5bu9JZOPCFqQOHDfnS13uT1fiQgsDfI&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.

Rich Shepard wrote

I need to import a lot of data each having one of several projections. It
is quicker for me to create a new location for each one, import it, then
re-project it to the base location and a layer-specific mapset. This
involves invoking grass, creating a new location, importing the .shp or
.gdb, shutting down grass, restarting grass in the base location,
re-projecting the new layer, then removing the (temporary) importing
location.

   Is there a way to switch locations within a running grass instance,
equivalent to creating/switching mapsets within a location?

Rich

_______________________________________________
grass-user mailing list

grass-user@.osgeo

https://lists.osgeo.org/mailman/listinfo/grass-user

another quite comfortable way may be:

reproject your data by ogr2ogr on the command line in a script, then do a
bulk import into grass

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html

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.

Much appreciated,

Rich

On Tue, 31 Oct 2017, Helmut Kudrnovsky wrote:

another quite comfortable way may be:
reproject your data by ogr2ogr on the command line in a script, then do a
bulk import into grass

Helmut,

   I like this.

   I'm completely re-organizing my grassdata directory; actually, really
organizing it. Each state will have its own location using NAD83(HARM) with
all layers in PERMANENT. Then each project will be a separate mapset.

   If there are alternative schemes, particularly using sub-directories for
locations (e.g., for counties within states) I would like a pointer to
references.

Thanks for the advice,

Rich

On Wed, Nov 1, 2017 at 12:21 AM, Rich Shepard <rshepard@appl-ecosys.com> 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
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

On Wed, 1 Nov 2017, Markus Metz wrote:

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,

   I did not pick this up reading the g.mapset manual page. I use this
regularly to change mapset focus and will now try it to change locations,
too.

Thank you,

Rich

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

[:blush:]

Chris

Chris Bartolomei P.E.
bartolomei.chris@ensco.com
________________________________
From: grass-user <grass-user-bounces@lists.osgeo.org> on behalf of Markus Metz <markus.metz.giswork@gmail.com>
Sent: Wednesday, November 1, 2017 12:38:07 AM
To: Rich Shepard
Cc: grass-user@lists.osgeo.org
Subject: Re: [GRASS-user] Switching locations on-the-fly

On Wed, Nov 1, 2017 at 12:21 AM, Rich Shepard <rshepard@appl-ecosys.com<mailto:rshepard@appl-ecosys.com>> 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
grass-user@lists.osgeo.org<mailto:grass-user@lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/grass-user&lt;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=&gt;

________________________________

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.

(attachments)

OutlookEmoji-😊.png

On Wed, 1 Nov 2017, Bartolomei.Chris wrote:

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

Chris,

   Thanks.

Rich