GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
g.findfile(1) GRASS GIS User's Manual g.findfile(1)

g.findfile - Searches for GRASS data base files and sets variables for the shell.

general, map management, scripts

g.findfile
g.findfile --help
g.findfile [-nl] element=string file=string [mapset=string] [--help] [--verbose] [--quiet] [--ui]

-n

Do not add quotes
-l

List available elements and exit
--help

Print usage summary
--verbose

Verbose module output
--quiet

Quiet module output
--ui

Force launching GUI dialog

element=string [required]

Name of an element
file=string [required]

Name of an existing map
mapset=string

Name of a mapset (default: search path)
’.’ for current mapset

g.findfile is designed for Bourne shell or Python scripts that need to search for mapset elements, including: raster, vector maps, region definitions and imagery groups.

The list of element names to search for is not fixed; any subdirectory of the mapset directory is a valid element name.

However, the user can find the list of standard GRASS element names in the file $GISBASE/etc/element_list. This is the file which g.remove, g.rename and g.copy use to determine which files need to be deleted/renamed/copied for a given entity type.

g.findfile writes four lines to standard output:

name=’file_name’
mapset=’mapset_name’
file=’unix_filename’
fullname=’grass_fullname
The output is Bash commands to set the variable name to the GRASS data base file name, mapset to the mapset in which the file resides, and file to the full UNIX path name for the named file. These variables may be set in the Bash as follows:

eval `g.findfile element=name mapset=name file=name`

Raster map example:

eval `g.findfile element=cell file=elevation`

If the specified file (here: raster map) does not exist, the variables will be set as follows:

name=
mapset=
fullname=
file=

The following is a way to test for this case:

if [ ! "$file" ]
then
	exit 1
fi

Vector map example (including error message):


eval `g.findfile element=vector file="$G_OPT_V_INPUT"`
if [ ! "$file" ] ; then
   g.message -e "Vector map <$G_OPT_V_INPUT> not found"
   exit 1
fi

See Python Scripting Library for more info.

Note: The Python tab in the wxGUI can be used for entering the following code:


import grass.script as gcore
gcore.find_file(’elevation’, element = ’cell’)

g.filename, g.gisenv, g.mapsets, g.parser

Michael Shapiro, U.S.Army Construction Engineering Research Laboratory

Available at: g.findfile source code (history)

Main index | General index | Topics index | Keywords index | Graphical index | Full index

© 2003-2021 GRASS Development Team, GRASS GIS 7.8.6 Reference Manual

GRASS 7.8.6

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.