123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- <!-- meta page description: GRASS startup program -->
- <h2>SYNOPSIS</h2>
- <b>grass73</b> [<b>-h</b> | <b>-help</b> | <b>--help</b>] [<b>-v</b> | <b>--version</b>]
- [<b>-c</b> | <b>-c geofile</b> | <b>-c EPSG:code[:datum_trans]</b>]
- [<b>-text</b> | <b>-gtext</b> | <b>-gui</b>]
- [[[<b><GISDBASE>/</b>]<b><LOCATION_NAME>/</b>]
- <b><MAPSET></b>]
- <h3>Flags:</h3>
- <dl>
- <dt><b>-h</b> | <b>-help</b> | <b>--help</b>
- <dd> Prints a brief usage message and exits
- <dt><b>-v</b> | <b>--verbose</b>
- <dd> Prints the version of GRASS and exits
- <dt><b>-c</b>
- <dd> Creates new GRASS unprojected location in specified GISDBASE
- <dt><b>-c geofile</b>
- <dd> Creates new GRASS projected location in specified GISDBASE based on georeferenced file
- <dt><b>-c EPSG:code</b>
- <dd> Creates new GRASS projected location in specified GISDBASE with given EPSG code
- <dt><b>-c EPSG:code:datum_trans</b>
- <dd> Creates new GRASS projected location in specified GISDBASE with given EPSG code and datum transform parameters
- <dt><b>-e</b>
- <dd> Exit after creation of location or mapset. Only with <b>-c</b> flag
- <dt><b>-f</b>
- <dd> Forces removal of .gislock if exists (use with care!). Only with -text flag
- <dt><b>-text</b>
- <dd> Indicates that Text-based User Interface should be used (skip welcome screen)
- <dt><b>-gtext</b>
- <dd> Indicates that Text-based User Interface should be used (show welcome screen)
- <dt><b>-gui</b>
- <dd> Indicates that Graphical User Interface
- (<em><a href="wxGUI.html">wxGUI</a></em>) should be used
- <dt><b>--config</b>
- <dd> Prints GRASS configuration parameters (options: arch, build, compiler, path, revision)
- <dt><b>--exec EXECUTABLE</b>
- <dd> Execute GRASS module or script. The provided executable will be executed in a GRASS GIS non-interactive session.
- </dl>
- <h3>Parameters:</h3>
- <dl>
- <dt><b>GISDBASE</b>
- <dd> Initial database directory which should be a fully qualified path
- (e.g., <tt>/usr/local/share/grassdata</tt>)
- <dt><b>LOCATION_NAME</b>
- <dd> Initial location directory which is a subdirectory of GISDBASE
- <dt><b>MAPSET</b>
- <dd> Initial mapset directory which is a subdirectory of LOCATION_NAME
- </dl>
- <i>Note</i>: These parameters must be specified in one of the
- following ways:
- <div class="code"><pre>
- MAPSET
- LOCATION_NAME/MAPSET
- GISDBASE/LOCATION_NAME/MAPSET
- </pre></div>
- <h2>DESCRIPTION</h2>
- <p>This command is used to launch GRASS GIS. It will parse the command
- line arguments and then initialize GRASS for the user. Since GRASS
- modules require a specific environment, this program must be called
- before any other GRASS module can run. The command line arguments are
- optional and provide the user with a method to indicate the desired
- user interface, as well as the desired mapset to work on.
- <p>The startup program will remember both the desired user interface
- and mapset. Thus, the next time the user runs GRASS, typing
- <em>grass73</em> (without any options) will start GRASS with the
- previous settings for the user interface and mapset selected.
- <p>If you specify a graphical user interface (<b>-gui</b>)
- the <em>grass73</em> program will try to verify that the system you
- specified exists and that you can access it successfully. If any of
- these checks fail then <em>grass73</em> will automatically switch back
- to the text user interface mode.
- <h2>SAMPLE DATA</h2>
- The GRASS GIS project provides several free sample geospatial datasets
- as ready-to-use locations. They are available to download at
- <a href="https://grass.osgeo.org/download/sample-data/">https://grass.osgeo.org/download/sample-data/</a>.
- The "North Carolina data set" is a modern package of geospatial data from
- North Carolina (USA), and it includes raster, vector, LiDAR and satellite
- data. This is the most extensively used data set in the documentation and
- the examples throughout the user manual pages are based upon it.
- <h2>ENVIRONMENT VARIABLES</h2>
- A number of environment variables are available at GRASS startup to
- assist with automation and customization. Most users will not need to
- bother with these.
- <p>In addition to these shell environment variables GRASS maintains a
- number of GIS environment variables in the <tt>$HOME/.grass7/rc</tt>
- file. User changes to this file will be read during the next startup
- of GRASS. If this file becomes corrupted the user may edit it by hand
- or remove it to start afresh. See the list
- of <em><a href="variables.html">implemented GRASS variables</a></em>
- for more information. The rest of this help page will only consider
- shell environment variables.
- <p>Note that you will need to set these variables using the
- appropriate method required for the UNIX shell that you use (e.g. in a
- Bash shell you must <tt>export</tt> the variables for them to
- propagate).
- <h3>User Interface Environment Variable</h3>
- <p>The <em>grass73</em> program will check for the existence of an
- environment variable called GRASS_GUI which indicates the type of user
- interface for GRASS to use. If this variable is not set
- when <em>grass73</em> is run, then it will be created and then saved
- in the <tt>$HOME/.grass7/rc</tt> file for the next time GRASS is
- run. It can be set to <tt>text</tt>, <tt>gtext</tt> or <tt>gui</tt>.
- <p>There is an order of precedence in the way <em>grass73</em>
- determines the user interface to use. The following is the hierarchy
- from highest precedence to lowest.
- <ol>
- <li>Command line argument
- <li>Environment variable GRASS_GUI
- <li>Value set in <tt>$HOME/.grass7/rc</tt> (GUI)
- <li>Default value - <tt>gui</tt>
- </ol>
- <h3>Python Environment Variables</h3>
- <p>If you choose to use <em><a href="wxGUI.html">wxGUI</a></em>
- interface, then the GRASS_PYTHON environment variable can be used to
- override your system default <tt>python</tt> command.
- <p>Suppose for example your system has Python 2.6 installed and you
- install a personal version of the Python 2.7 binaries
- under <tt>$HOME/bin</tt>. You can use the above variables to have
- GRASS use the Python 2.7 binaries instead.
- <div class="code"><pre>
- GRASS_PYTHON=python2.7
- </pre></div>
- <h3>Addon Path to Extra User Scripts</h3>
- This environment variable allows the user to extend the GRASS program
- search paths to include locally developed/installed GRASS modules or
- user scripts.
- <div class="code"><pre>
- GRASS_ADDON_PATH=/usr/mytools
- GRASS_ADDON_PATH=/usr/mytools:/usr/local/othertools
- </pre></div>
- <p>In this example above path(s) would be added to the standard GRASS path
- environment.
- <h3>Addon Base for Extra Local GRASS Addon Modules</h3>
- This environment variable allows the user to extend the GRASS program
- search paths to include locally installed
- (see <em><a href="g.extension.html">g.extension</a></em> for details)
- <a href="http://grasswiki.osgeo.org/wiki/GRASS_AddOns">GRASS Addon</a>
- modules which are not distributed with the standard GRASS release.
- <div class="code"><pre>
- GRASS_ADDON_BASE=/usr/grass-addons
- </pre></div>
- <p>In this example above path would be added to the standard GRASS
- path environment.
- <p>If not defined by user, this variable is set by GRASS startup program
- to <tt>$HOME/.grass7/addons</tt> on GNU/Linux
- and <tt>$APPDATA\GRASS7\addons</tt> on MS Windows.
- <h3>HTML Browser Variable</h3>
- The GRASS_HTML_BROWSER environment variable allows the user to set the
- HTML web browser to use for displaying help pages.
- <h3>Location Environment Variables</h3>
- <p>The <b>Synopsis</b> section above describes options that can be used
- to set the location and mapset that GRASS will use. These values can
- also be set with environment variables. However, specifying the
- location and mapset variables on the command line will override these
- environment variables. The available variables are as follows:
- <dl>
- <dt>LOCATION
- <dd> A fully qualified path to a mapset
- (eg <tt>/usr/local/share/grassdata/spearfish70/PERMANENT</tt>). This
- environment variable overrides the GISDBASE, LOCATION_NAME, and
- MAPSET variables.
- <dt>GISDBASE
- <dd> Initial database directory which should be a fully qualified path
- (eg <tt>/usr/local/share/grassdata</tt>)
- <dt>LOCATION_NAME
- <dd> Initial location directory which is a subdirectory of GISDBASE
- <dt>MAPSET
- <dd> Initial mapset directory which is a subdirectory of LOCATION_NAME
- </dl>
- <h3>Running non-interactive batch jobs</h3>
- If the GRASS_BATCH_JOB environment variable is set to the <i>full</i>
- path and filename of a shell script then GRASS will be launched in a
- non-interactive way and the script will be run. The script itself can
- be interactive if that is what the user requires. When it is finished
- GRASS will automatically exit using the exit-success code given by the
- script. The script file must have its executable bit set.
- <h2>EXAMPLES</h2>
- <p>The following are some examples of how you could start GRASS
- <dl>
- <dt><b>grass73</b>
- <dd> Start GRASS using the default user interface. The user will be
- prompted to choose the appropriate location and mapset.
- <dt><b>grass73 -gui</b>
- <dd> Start GRASS using the graphical user interface. The user will be
- prompted to choose the appropriate location and mapset.
- <dt><b>grass73 -text</b>
- <dd> Start GRASS using the text-based user interface. Appropriate
- location and mapset must be set by environmental variables (see
- examples below) otherwise taken from the last GRASS session.</dd>
- <dt><b>grass73 -gtext</b>
- <dd> Start GRASS using the text-based user interface. The user will be
- prompted to choose the appropriate location and mapset.
- <dt><b>grass73 $HOME/grassdata/spearfish70/user1</b>
- <dd> Start GRASS using the default user interface and automatically
- launch into the given mapset, bypassing the mapset selection menu.
- <dt><b>grass73 -gui -</b>
- <dd> Start GRASS using the graphical user interface and try to
- obtain the location and mapset from environment variables.
- <dt><b>grass73 -c EPSG:4326 $HOME/grassdata/mylocation</b>
- <dd> Creates new GRASS location with EPSG code 4326 (latitude-longitude, WGS84)
- in the specified GISDBASE
- <dt><b>grass73 -c EPSG:5514:3 $HOME/grassdata/mylocation</b>
- <dd> Creates new GRASS location with EPSG code 5514 (S-JTSK / Krovak
- East North - SJTSK) with datum transformation parameters used in
- Czech Republic in the specified GISDBASE
- <dt><b>grass73 -c myvector.shp $HOME/grassdata/mylocation</b>
- <dd> Creates new GRASS location based on georeferenced Shapefile
- <dt><b>grass73 -c myraster.tif $HOME/grassdata/mylocation</b>
- <dd> Creates new GRASS location based on georeferenced GeoTIFF file
- </dl>
- <h3>Batch jobs with the exec interface</h3>
- <!--
- Data created with:
- r.out.gdal input=elevation output=elevation.tiff
- r.out.gdal input=basin_50K output=basins.tiff
- Region issues ignored.
- -->
- Creating a new Location based on a geodata file's projection (<b>-c</b>)
- and exit (<b>-e</b>) immediately:
- <div class="code"><pre>
- grass73 -c elevation.tiff -e /path/to/grassdata/test1/
- </pre></div>
- Linking external raster data to PERMANENT Mapset:
- <div class="code"><pre>
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec r.external input=basins.tiff output=basins
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec r.external input=elevation.tiff output=elevation
- </pre></div>
- Get statistics for one raster map:
- <div class="code"><pre>
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec r.univar map=elevation
- </pre></div>
- Compare the rasters visually:
- <div class="code"><pre>
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec g.gui.mapswipe first=elevation second=basins
- </pre></div>
- <h4>Execution of shell and Python scripts instead of single commands</h4>
- A sequence of commands can be bundled in a script and executed using the
- exec interface.
- <p>
- <b>Shell script example:</b> the command to execute a shell script might be:
- <div class="code"><pre>
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec sh test.sh
- </pre></div>
- A very simple bash script ("test.sh") may look like this:
- <div class="code"><pre>
- #!/bin/bash
- g.region -p
- g.list type=raster
- r.info elevation
- </pre></div>
- <p>
- <b>Python script example:</b> the command to execute a Python script might be:
- <div class="code"><pre>
- grass73 /path/to/grassdata/test1/PERMANENT/ --exec python test.py
- </pre></div>
- A very simple Python script ("test.py") may look like this:
- <div class="code"><pre>
- #!/usr/bin/env python
- # import GRASS Python bindings (see also pygrass)
- import grass.script as gscript
- import grass.script.setup as gsetup
- gscript.message('Current GRASS GIS 7 environment:')
- print(gscript.gisenv())
- gscript.message('Available raster maps:')
- for raster in gscript.list_strings(type='raster'):
- print(raster)
- gscript.message('Available vector maps:')
- for vector in gscript.list_strings(type='vector'):
- print(vector)
- </pre></div>
- <h4>Troubleshooting</h4>
- Importantly, to avoid an <tt>"[Errno 8] Exec format error"</tt> there must be a
- <a href="https://en.wikipedia.org/wiki/Shebang_%28Unix%29">shebang</a> line at the top of
- the script (like <tt>#!/bin/sh</tt>, <tt>#!/bin/bash</tt>, or <tt>#!/usr/bin/env python</tt>)
- indicating which interpreter to be used for the script. The script file must
- have its executable bit set.
- <h3>Other examples</h3>
- There are a variety of ways in which the <i>location environment
- variables</i> (see above) can be used to specify the mapset to use.
- The following are some possible examples.
- <h4>Example 1</h4>
- The environment variables are defined as follows:
-
- <div class="code"><pre>
- LOCATION = /usr/local/share/grassdata/spearfish70/PERMANENT
- GISDBASE = /usr/local/share/grassdata
- LOCATION_NAME = spearfish70
- MAPSET = PERMANENT
- </pre></div>
- Start GRASS with the following command:
- <div class="code"><pre>
- grass73 -
- </pre></div>
- GRASS will start with the mapset defined by LOCATION since the LOCATION
- variable overrides the other variables.
- <h4>Example 2</h4>
- The environment variables are defined as follows:
-
- <div class="code"><pre>
- GISDBASE = /usr/local/share/grassdata
- LOCATION_NAME = spearfish70
- MAPSET = PERMANENT
- </pre></div>
- Start GRASS with the following command:
- <div class="code"><pre>
- grass73 -
- </pre></div>
-
- GRASS will start with the mapset defined by
- GISDBASE/LOCATION_NAME/MAPSET.
- <div class="code"><pre>
- grass73 /usr/home/grass/data/thailand/forests
- </pre></div>
-
- GRASS will start with the
- mapset <tt>/home/grass/data/thailand/forests</tt> which overrides the
- environment variables.
- <div class="code"><pre>
- grass73 swamps
- </pre></div>
- GRASS will start with the mapset defined by
- GISDBASE/LOCATION_NAME/swamps since the command line argument for the
- mapset overrides the environment variable MAPSET.
- <div class="code"><pre>
- grass73 thailand/forests
- </pre></div>
- GRASS will start with the mapset defined by GISDBASE/thailand/forests
- since the command line arguments for the location and mapset overrides
- the environment variables LOCATION_NAME and MAPSET.
- <h2>CAVEAT</h2>
- If you start GRASS using the <em><a href="wxGUI.html">wxGUI</a></em>
- interface you must have a <tt>python</tt> command in your $PATH
- variable. That is, the command must be named
- <tt>python</tt> and not something like <tt>python2.6</tt>. Rarely some
- Python installations do not create a <tt>python</tt> command. In these
- cases you can override <tt>python</tt> by GRASS_PYTHON environmental
- variable.
- <p>Furthermore, if you have more than one version of Python installed,
- make sure that the version you want to use with GRASS is set by
- GRASS_PYTHON environmental variable.
- <h2>SEE ALSO</h2>
- List of <a href="variables.html">GRASS environment variables</a>
- <p>
- <a href="http://grass.osgeo.org">GRASS GIS Web site</a><br>
- <a href="http://grass.osgeo.org/wiki/">GRASS GIS User Wiki</a><br>
- <a href="http://trac.osgeo.org/grass/">GRASS GIS Bug Tracker</a><br>
- <a href="http://grass.osgeo.org/programming7/">GRASS GIS 7 Programmer's
- Manual</a>
- <h2>AUTHORS (of this page)</h2>
- Justin Hickey<br>
- Markus Neteler<br>
- Hamish Bowman<br>
- Martin Landa, Czech Technical University in Prague, Czech Republic
- <p>
- <i>Last changed: $Date$</i>
|