1grass7(1) Grass User's Manual grass7(1)
2
3
4
7 grass76 [-h | -help | --help] [-v | --version] [-c | -c geofile | -c
8 EPSG:code[:datum_trans]] [--text | --gtext | --gui] [[[<GISD‐
9 BASE>/]<LOCATION>/] <MAPSET>]
10
11 Flags:
12 -h | -help | --help
13 Prints a brief usage message and exits
14
15 -v | --verbose
16 Prints the version of GRASS and exits
17
18 -c
19 Creates new GRASS unprojected location in specified GISDBASE
20
21 -c geofile
22 Creates new GRASS projected location in specified GISDBASE based on
23 georeferenced file
24
25 -c EPSG:code
26 Creates new GRASS projected location in specified GISDBASE with
27 given EPSG code
28
29 -c EPSG:code:datum_trans
30 Creates new GRASS projected location in specified GISDBASE with
31 given EPSG code and datum transform parameters
32
33 -e
34 Exit after creation of location or mapset. Only with -c flag
35
36 -f
37 Forces removal of .gislock if exists (use with care!). Only with
38 --text flag
39
40 --text
41 Indicates that Text-based User Interface should be used (skip wel‐
42 come screen)
43
44 --gtext
45 Indicates that Text-based User Interface should be used (show wel‐
46 come screen)
47
48 --gui
49 Indicates that Graphical User Interface (wxGUI) should be used
50
51 --config
52 Prints GRASS configuration parameters (options: arch, build, com‐
53 piler, path, revision)
54
55 --exec EXECUTABLE
56 Execute GRASS module or script. The provided executable will be
57 executed in a GRASS GIS non-interactive session.
58
59 --tmp-location
60 Run using a temporary location which is created based on the given
61 coordinate reference system and deleted at the end of the execution
62 (use the --exec flag). The active mapset will be PERMANENT.
63
64 Parameters:
65 GISDBASE
66 Initial database directory which should be a fully qualified path
67 (e.g., /usr/local/share/grassdata)
68
69 LOCATION
70 Initial location directory which is a subdirectory of GISDBASE
71
72 MAPSET
73 Initial mapset directory which is a subdirectory of LOCATION Note:
74 These parameters must be specified in one of the following ways:
75 MAPSET
76 LOCATION/MAPSET
77 GISDBASE/LOCATION/MAPSET
78
80 This command is used to launch GRASS GIS. It will parse the command
81 line arguments and then initialize GRASS for the user. Since GRASS mod‐
82 ules require a specific environment, this program must be called before
83 any other GRASS module can run. The command line arguments are optional
84 and provide the user with a method to indicate the desired user inter‐
85 face, as well as the desired mapset to work on.
86
87 The startup program will remember both the desired user interface and
88 mapset. Thus, the next time the user runs GRASS, typing grass76 (with‐
89 out any options) will start GRASS with the previous settings for the
90 user interface and mapset selected.
91
92 If you specify a graphical user interface (--gui) the grass76 program
93 will try to verify that the system you specified exists and that you
94 can access it successfully. If any of these checks fail then grass76
95 will automatically switch back to the text user interface mode.
96
98 The GRASS GIS project provides several free sample geospatial datasets
99 as ready-to-use locations. They are available to download at
100 https://grass.osgeo.org/download/sample-data/. The "North Carolina
101 data set" is a modern package of geospatial data from North Carolina
102 (USA), and it includes raster, vector, LiDAR and satellite data. This
103 is the most extensively used data set in the documentation and the
104 examples throughout the user manual pages are based upon it.
105
107 A number of environment variables are available at GRASS startup to
108 assist with automation and customization. Most users will not need to
109 bother with these.
110
111 In addition to these shell environment variables GRASS maintains a num‐
112 ber of GIS environment variables in the $HOME/.grass7/rc file. User
113 changes to this file will be read during the next startup of GRASS. If
114 this file becomes corrupted the user may edit it by hand or remove it
115 to start afresh. See the list of implemented GRASS variables for more
116 information. The rest of this help page will only consider shell envi‐
117 ronment variables.
118
119 Note that you will need to set these variables using the appropriate
120 method required for the UNIX shell that you use (e.g. in a Bash shell
121 you must export the variables for them to propagate).
122
123 User Interface Environment Variable
124 The grass76 program will check for the existence of an environment
125 variable called GRASS_GUI which indicates the type of user interface
126 for GRASS to use. If this variable is not set when grass76 is run, then
127 it will be created and then saved in the $HOME/.grass7/rc file for the
128 next time GRASS is run. It can be set to text, gtext or gui.
129
130 There is an order of precedence in the way grass76 determines the user
131 interface to use. The following is the hierarchy from highest prece‐
132 dence to lowest.
133
134 1 Command line argument
135
136 2 Environment variable GRASS_GUI
137
138 3 Value set in $HOME/.grass7/rc (GUI)
139
140 4 Default value - gui
141
142 Python Environment Variables
143 If you choose to use wxGUI interface, then the GRASS_PYTHON environment
144 variable can be used to override your system default python command.
145
146 Suppose for example your system has Python 2.6 installed and you
147 install a personal version of the Python 2.7 binaries under $HOME/bin.
148 You can use the above variables to have GRASS use the Python 2.7 bina‐
149 ries instead.
150 GRASS_PYTHON=python2.7
151
152 Addon Path to Extra User Scripts
153 This environment variable allows the user to extend the GRASS program
154 search paths to include locally developed/installed GRASS modules or
155 user scripts.
156 GRASS_ADDON_PATH=/usr/mytools
157 GRASS_ADDON_PATH=/usr/mytools:/usr/local/othertools
158
159 In this example above path(s) would be added to the standard GRASS path
160 environment.
161
162 Addon Base for Extra Local GRASS Addon Modules
163 This environment variable allows the user to extend the GRASS program
164 search paths to include locally installed (see g.extension for details)
165 GRASS Addon modules which are not distributed with the standard GRASS
166 release.
167 GRASS_ADDON_BASE=/usr/grass-addons
168
169 In this example above path would be added to the standard GRASS path
170 environment.
171
172 If not defined by user, this variable is set by GRASS startup program
173 to $HOME/.grass7/addons on GNU/Linux and $APPDATA\GRASS7\addons on MS
174 Windows.
175
176 HTML Browser Variable
177 The GRASS_HTML_BROWSER environment variable allows the user to set the
178 HTML web browser to use for displaying help pages.
179
180 Location Environment Variables
181 The Synopsis section above describes options that can be used to set
182 the location and mapset that GRASS will use. These values can also be
183 set with environment variables. However, specifying the location and
184 mapset variables on the command line will override these environment
185 variables. The available variables are as follows:
186
187 LOCATION
188 A fully qualified path to a mapset (eg /usr/local/share/grass‐
189 data/spearfish70/PERMANENT). This environment variable overrides
190 the GISDBASE, LOCATION_NAME, and MAPSET variables.
191
192 GISDBASE
193 Initial database directory which should be a fully qualified path
194 (eg /usr/local/share/grassdata)
195
196 LOCATION_NAME
197 Initial location directory which is a subdirectory of GISDBASE
198
199 MAPSET
200 Initial mapset directory which is a subdirectory of LOCATION_NAME
201
202 Running non-interactive batch jobs
203 If the GRASS_BATCH_JOB environment variable is set to the full path and
204 filename of a shell script then GRASS will be launched in a non-inter‐
205 active way and the script will be run. The script itself can be inter‐
206 active if that is what the user requires. When it is finished GRASS
207 will automatically exit using the exit-success code given by the
208 script. The script file must have its executable bit set.
209
211 The following are some examples of how you could start GRASS
212
213 grass76
214 Start GRASS using the default user interface. The user will be
215 prompted to choose the appropriate location and mapset.
216
217 grass76 --gui
218 Start GRASS using the graphical user interface. The user will be
219 prompted to choose the appropriate location and mapset.
220
221 grass76 --text
222 Start GRASS using the text-based user interface. Appropriate loca‐
223 tion and mapset must be set by environmental variables (see exam‐
224 ples below) otherwise taken from the last GRASS session.
225
226 grass76 --gtext
227 Start GRASS using the text-based user interface. The user will be
228 prompted to choose the appropriate location and mapset.
229
230 grass76 $HOME/grassdata/spearfish70/user1
231 Start GRASS using the default user interface and automatically
232 launch into the given mapset, bypassing the mapset selection menu.
233
234 grass76 --gui -
235 Start GRASS using the graphical user interface and try to obtain
236 the location and mapset from environment variables.
237
238 grass76 -c EPSG:4326 $HOME/grassdata/mylocation
239 Creates a new GRASS location with EPSG code 4326 (latitude-longi‐
240 tude, WGS84) in the specified GISDBASE
241
242 grass76 -c EPSG:5514:3 $HOME/grassdata/mylocation
243 Creates a new GRASS location with EPSG code 5514 (S-JTSK / Krovak
244 East North - SJTSK) with datum transformation parameters used in
245 Czech Republic in the specified GISDBASE
246
247 grass76 -c XY $HOME/grassdata/gnomonic --exec g.proj -c
248 proj4=’+proj=gnom +lat_0=90 +lon_0=-50’
249 Creates a new GRASS location from PROJ definition string (here:
250 gnomonic) in the specified GISDBASE
251
252 grass76 -c myvector.shp $HOME/grassdata/mylocation
253 Creates a new GRASS location based on georeferenced Shapefile
254
255 grass76 -c myraster.tif $HOME/grassdata/mylocation
256 Creates a new GRASS location based on georeferenced GeoTIFF file
257
258 Batch jobs with the exec interface
259 Creating a new Location based on a geodata file’s projection (-c) and
260 exit (-e) immediately:
261 grass76 -c elevation.tiff -e /path/to/grassdata/test1/
262 Linking external raster data to PERMANENT Mapset:
263 grass76 /path/to/grassdata/test1/PERMANENT/ --exec r.external input=basins.tiff output=basins
264 grass76 /path/to/grassdata/test1/PERMANENT/ --exec r.external input=elevation.tiff output=elevation
265 Get statistics for one raster map:
266 grass76 /path/to/grassdata/test1/PERMANENT/ --exec r.univar map=elevation
267 Compare the rasters visually:
268 grass76 /path/to/grassdata/test1/PERMANENT/ --exec g.gui.mapswipe first=elevation second=basins
269
270 Execution of shell and Python scripts instead of single commands
271 A sequence of commands can be bundled in a script and executed using
272 the exec interface.
273
274 Shell script example: the command to execute a shell script might be:
275 grass76 /path/to/grassdata/test1/PERMANENT/ --exec sh test.sh
276 A very simple bash script ("test.sh") may look like this:
277 #!/bin/bash
278 g.region -p
279 g.list type=raster
280 r.info elevation
281
282 Python script example: the command to execute a Python script might be:
283 grass76 /path/to/grassdata/test1/PERMANENT/ --exec python test.py
284 A very simple Python script ("test.py") may look like this:
285 #!/usr/bin/python2
286 # import GRASS Python bindings (see also pygrass)
287 import grass.script as gscript
288 import grass.script.setup as gsetup
289 gscript.message(’Current GRASS GIS 7 environment:’)
290 print(gscript.gisenv())
291 gscript.message(’Available raster maps:’)
292 for raster in gscript.list_strings(type=’raster’):
293 print(raster)
294 gscript.message(’Available vector maps:’)
295 for vector in gscript.list_strings(type=’vector’):
296 print(vector)
297
298 Using temporary location
299 Creating a new temporary location based on a georeferenced file’s pro‐
300 jection coordinate reference system (CRS) and simultaneously starting
301 computation in a shell script:
302 grass76 --tmp-location elevation.tiff --exec test.sh
303 The same, but using an EPSG code and a Python script:
304 grass76 --tmp-location EPSG:3358 --exec test.py
305 Finally, for special cases, we can create an XY location without any
306 CRS:
307 grass76 --tmp-location XY --exec test.py
308 Temporary location is automatically deleted after computation, so the
309 script is expected to export, link or otherwise preserve the output
310 data before ending.
311
312 A single command can be also executed, e.g. to examine properties of
313 the temporary location:
314 grass76 --tmp-location EPSG:3358 --exec g.proj -p
315 A temporary XY location with single command is useful, e.g. to show
316 help text of a module:
317 grass76 --tmp-location XY --exec r.neighbors --help
318
319 Troubleshooting
320 Importantly, to avoid an "[Errno 8] Exec format error" there must be a
321 shebang line at the top of the script (like #!/bin/sh, #!/bin/bash, or
322 #!/usr/bin/python2) indicating which interpreter to be used for the
323 script. The script file must have its executable bit set.
324
326 If you start GRASS using the wxGUI interface you must have a python
327 command in your $PATH variable. That is, the command must be named
328 python and not something like python2.6. Rarely some Python installa‐
329 tions do not create a python command. In these cases you can override
330 python by GRASS_PYTHON environmental variable.
331
332 Furthermore, if you have more than one version of Python installed,
333 make sure that the version you want to use with GRASS is set by
334 GRASS_PYTHON environmental variable.
335
337 List of GRASS environment variables
338
339 GRASS GIS Web site
340 GRASS GIS User Wiki
341 GRASS GIS Bug Tracker
342 GRASS GIS 7 Programmer’s Manual
343
345 Justin Hickey
346 Markus Neteler
347 Hamish Bowman
348 Martin Landa, Czech Technical University in Prague, Czech Republic
349
350 Last changed: $Date: 2018-11-30 12:44:28 +0100 (Fri, 30 Nov 2018) $
351
352 Main index | Topics index | Keywords index | Graphical index | Full
353 index
354
355 © 2003-2019 GRASS Development Team, GRASS GIS 7.6.0 Reference Manual
356
357
358
359GRASS 7.6.0 grass7(1)