[GRASS-user] Raster names under Linux

Hi,

I wrote a script for GRASS 6.4 under Ubuntu, in which I included
the commands r.in.gdal and g.region rast=xxx. When runningthe script
I received error messages illegal file name and character <not allowed.
How could I overcome this problem ?

Best regards

Niels

-----------------------------------------------------
Dr. Niels Thevs
Institute of Botany and Landscape Ecology
Greifswald University
Grimmer Strasse 88
17487 Greifswald
Germany

Tel.: +49-3834-86-4132
Fax: +49-3834-86-4114

===================================================================
WEB-Mailer der Uni-Greifswald ( http://www.uni-greifswald.de/ )

On Tue, 2 Feb 2010, Niels Thevs wrote:

I wrote a script for GRASS 6.4 under Ubuntu, in which I included the
commands r.in.gdal and g.region rast=xxx. When runningthe script I
received error messages illegal file name and character <not allowed. How
could I overcome this problem ?

Niels,

   Do the file names contain an underscore '_'? GRASS doesn't like that.
Hyphens ('-') seem to be OK.

Rich

Rich Shepard wrote:

> I wrote a script for GRASS 6.4 under Ubuntu, in which I included the
> commands r.in.gdal and g.region rast=xxx. When runningthe script I
> received error messages illegal file name and character <not allowed. How
> could I overcome this problem ?

Niels,

   Do the file names contain an underscore '_'? GRASS doesn't like that.
Hyphens ('-') seem to be OK.

There are no problems with underscores in map names.

[However, if you're writing a shell script, you need to bear in mind
that underscores are allowed in variable names, so "$foo_bar" means
the value of the variable named "foo_bar". If you want the value of
the variable "foo" followed by the literal text "_bar", you need to
put braces around the variable name, i.e. "${foo}_bar".]

The characters which aren't allowed in map names, mapset names, etc
are:

  / " ' @ , = *

plus space (32), control characters (< 32), delete (127), and 8-bit
characters (>= 128).

On Windows[1], the following characters are also prohibited:

  \ : ? < > |

[1] The prohibition also applies when using DOS/Windows filesystems
(FAT, VFAT, NTFS, SMBFS/CIFS) on e.g. Linux.

In r.mapcalc, a map name needs to be quoted if it contains any of the
following characters:

  ^ # ( ) + - % > < ! & | ? : ; ~

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

Niels:

> I wrote a script for GRASS 6.4 under Ubuntu, in which
> I included the commands r.in.gdal and g.region rast=xxx.
> When runningthe script I received error messages illegal
> file name and character <not allowed. How could I overcome
> this problem ?

quoting error? non-english character?

Rich wrote:

Do the file names contain an underscore '_'? GRASS
doesn't like that. Hyphens ('-') seem to be OK.

? underscores are fine. Hyphens are ok for raster maps but
must be quoted for r.mapcalc so it doesn't mistake it for a
minus sign. Vector names must be SQL compliant (stricker set,
can't start with a number, ...)

the full list of bannded chars for all GRASS maps/regions can
be found in lib/gis/legal_nme.c:

if (*s == '/' || *s == '"' || *s == '\'' || *s <= ' ' ||
    *s == '@' || *s == ',' || *s == '=' || *s == '*' || *s > 0176) {
   fprintf(stderr,
      _("Illegal filename. Character <%c> not allowed.\n"), *s);
        return -1;

Hamish

On Tue, 2 Feb 2010, Hamish wrote:

? underscores are fine.

Hamish,

   I responded off the top of my head, and it was the use of periods in file
names (which I use liberally in regular file names) that caused GRASS to
complain.

Mea culpa!

Rich

Rich Shepard wrote:

> ? underscores are fine.

Hamish,

   I responded off the top of my head, and it was the use of periods in file
names (which I use liberally in regular file names) that caused GRASS to
complain.

Odd. Those are fine too, and quite common (the spearfish dataset
contains several raster maps with periods).

Vector maps are limited to alphanumerics and underscores due to SQL.
That's something we could change easily enough, though. There's no
fundamental reason why the attribute table must have exactly the same
name as the map.

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

On Wed, 3 Feb 2010, Glynn Clements wrote:

Odd. Those are fine too, and quite common (the spearfish dataset contains
several raster maps with periods).

Glynn,

   It could have been vector maps instead of rasters.

Vector maps are limited to alphanumerics and underscores due to SQL.
That's something we could change easily enough, though. There's no
fundamental reason why the attribute table must have exactly the same name
as the map.

   No, there isn't. But it makes it easier to read. I'd stay with the SQL
standard for file names.

Rich

Dear Glynn,

maybe the problem is the format of the hard disk. I use a partition formatted in FAT32 for Windows and Linux. I will try the script opration on the Linux partition.

Best regards

Niels

Glynn Clements schrieb:

Rich Shepard wrote:

I wrote a script for GRASS 6.4 under Ubuntu, in which I included the
commands r.in.gdal and g.region rast=xxx. When runningthe script I
received error messages illegal file name and character <not allowed. How
could I overcome this problem ?

Niels,

   Do the file names contain an underscore '_'? GRASS doesn't like that.
Hyphens ('-') seem to be OK.

There are no problems with underscores in map names.

[However, if you're writing a shell script, you need to bear in mind
that underscores are allowed in variable names, so "$foo_bar" means
the value of the variable named "foo_bar". If you want the value of
the variable "foo" followed by the literal text "_bar", you need to
put braces around the variable name, i.e. "${foo}_bar".]

The characters which aren't allowed in map names, mapset names, etc
are:

  / " ' @ , = *

plus space (32), control characters (< 32), delete (127), and 8-bit
characters (>= 128).

On Windows[1], the following characters are also prohibited:

  \ : ? < > |

[1] The prohibition also applies when using DOS/Windows filesystems
(FAT, VFAT, NTFS, SMBFS/CIFS) on e.g. Linux.

In r.mapcalc, a map name needs to be quoted if it contains any of the
following characters:

  ^ # ( ) + - % > < ! & | ? : ; ~

--

-----------------------------------------------------
Dr. Niels Thevs
Institute of Botany and Landscape Ecology
Greifswald University
Grimmer Strasse 88
17487 Greifswald
Germany

Tel.: +49-3834-86-4131
Fax: +49-3834-86-4114

-----------------------------------------------------