[GRASS-user] location/mapset naming restrictions

Glynn Clements glynn at gclements.plus.com
Mon Nov 30 17:40:10 PST 2015


Panagiotis Mavrogiorgos wrote:

> Are there any restrictions to the location/mapset names?

They may not contain any of the characters:

	/ " ' @ , = *

or space, DEL (code 127/0x7F), any control character or any 8-bit
character.

[source: lib/gis/legal_name.c]

Also, because map, mapset and location names are used directly as file
and/or directory names, they may not contain any character which is
prohibited in a filename by the underlying OS. On Windows, this
includes:

	\ / : * ? " < > |

[source: try entering any of these characters when renaming a file or
directory on Windows.]

The OS may also impose other restrictions (e.g. you typically can't
have a file or directory named "." or ".." although the "." character
isn't itself prohibited).

> I just found out that if you use a numeric mapset (e.g. 2014_123) you have
> to use single quotes in mapcalc expressions.

Which names are legal and which names can be used in r.mapcalc without
quoting are different. E.g. a "-" character (minus, hyphen, dash) is
legal in a map, mapset or location name, but r.mapcalc requires the
name to be quoted, otherwise it will be interpreted as a subtraction.

> e.g the following example will
> raise an error:
> 
> r.mapcalc expression="foo=R1 at 2014_123"
> 
> results in:
> 
> syntax error, unexpected INTEGER, expecting VARNAME or NAME

An unquoted name consists of a sequence of characters other than
space, control characters, or any of:


	^ # @ , " ' ( ) [ ] + - * / % > < ! = & | ? : ; ~ 

[source: raster/r.mapcalc/mapcalc.l, definition of "N" (line 97).]

*However*: it may not have a prefix which is a valid integer or
floating-point literal (which is why your example above generates an
error), as those take precedence over names.

A quoted name can contain any character other than the quote character
itself. Note that quoted names aren't always maps (or mapsets or
locations); they can also be used for variables if you feel you have
to use a name which isn't valid as an unquoted name.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list