[GRASS-user] Shell scripts to define GISDATABASE, location, and mapset; import data
Micha Silver
tsvibar at gmail.com
Fri Apr 28 04:02:35 PDT 2023
Hi Rich:
On 28/04/2023 0:56, Rich Shepard wrote:
> I write shell scripts to run modules for analyses, but have always
> used the
> GUI to define locations and/or mapsets before importing data even with
> starting
> grass with the -c option.
>
> What I want to do now when importing project data is to have a script
> that
> defines the location and mapset then imports the data.
>
> I've read the startup program manual page
> <https://grass.osgeo.org/grass82/manuals/grass.html> several times today
> without seeing how to specify the all three parameters to define a
> location
> and mapset and immediately follow that with a data import command; is
> --exec
> really necessary?
>
Here's your script with corrections
#!/usr/bin/bash
# set grass location for quarry boundary map
grass -c
$HOME/projects/oregon/northside-rock/data/data/property/Tax_Lots.shp
/data1/grassdata/quarry-name/permitted-boundary
# Import quarry boundary map
# Comments:
# The 'output' parameter should be just a grass vector name, NOT a path.
# Best to use underscore in map names, NOT '-'
# And '--overwrite' == '--o'
v.import
input=$HOME/projects/oregon/northside-rock/data/property/Tax_Lots.shp
output=permitted_boundary --overwrite
One additional point that might make this easier: GRASS locations are
typically defined by a coordinate reference system. If you work with
data in only a few CRS, then you can consider to create a collections of
locations, one for each CRS that you use. Then when you start a new
project, open grass in the location that contains data in the CRS of the
project, and create a new *mapset* just for that project. Then import
into that mapset. This approach has two advantages: (1) - You don't need
to be creating new locations all the time with possibly redundant CRS
definitions. And (2) - you most likely have some data that can be
shared between projects. With one overall location defined by i.e.
"NAD83(HARN) Oregon", then you can store in the PERMANENT mapset any
dataset that might be shared among projects. And each mapset will be
specific to one project.
Creating a new project specific mapset, within an existing location is
done by:
# Start GRASS in existing location
grass /data/grassdata/some_location/PERMANENT
# create new mapset
g.mapset -c <new_project_name>
# Now import whatever data you need
v.import input=...
Best, Micha
> An example file is attached. Please correct my format and I'll use
> this as a
> template for all data imports.
>
> TIA,
>
> Rich
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
More information about the grass-user
mailing list