[GRASS-user] r.fillnulls error

Hi,

I'm trying to use r.fillnulls for a DTM generated importing srtm data , but it does' t work. This is the message:
                                                     
r.fillnulls --overwrite input=14@PERMANENT output=14_int
Locating and isolating NULL areas...
syntax error, unexpected '@', expecting ')'
Parse error
ERROR: Raster map <r_fillnulls_49960> not found
ERROR: /Applications/GRASS-6.4.app/Contents/MacOS/scripts/r.fillnulls abandoned. Removing temporary map, restoring user mask if needed:
Removing raster <MASK>
Raster map <MASK> not found
<MASK> nothing removed
Removing raster <r_fillnulls_49960>
Raster map <r_fillnulls_49960> not found
<r_fillnulls_49960> nothing removed
Removing raster <r_fillnulls_49960.buf>
Raster map <r_fillnulls_49960.buf> not found
<r_fillnulls_49960.buf> nothing removed
Removing raster <r_fillnulls_49960_filled>
Raster map <r_fillnulls_49960_filled> not found
<r_fillnulls_49960_filled> nothing removed
raster <usermask_mask.49960> not found
(Fri Sep 9 19:08:00 2011) Command finished (0 sec)

Salvatore wrote:

I'm trying to use r.fillnulls for a DTM generated importing
srtm data , but it does' t work. This is the message:

r.fillnulls --overwrite input=14@PERMANENT output=14_int

Locating and isolating NULL areas...
syntax error, unexpected '@', expecting ')'
Parse error

r.mapcalc is unhappy because the map name isn't quoted internally
and it can't decide if the map name is a number or a name. I think
the same would happen if you had a "-" in the map name. If you
don't include the @mapset part it still runs, but the result
is no good as isnull(14) is always false if it thinks 14 is a
number.

quick work-around: rename the map to add a letter before the "14".

this bug is hopefully fixed in devbr6 with r48227, after testing
it should be backported to 6.4svn.

I am not sure if "$input" needs to be quoted or not in the
trunk python version:

    #creating 0/1 map:
    grass.mapcalc("$tmp1 = if(isnull($input),1,null())",
                  tmp1 = tmp1, input = input)

?

Hamish

Hamish wrote:

I am not sure if "$input" needs to be quoted or not in the
trunk python version:

    #creating 0/1 map:
    grass.mapcalc("$tmp1 = if(isnull($input),1,null())",
                  tmp1 = tmp1, input = input)

If a map name can be interpreted as a number[1], or it contains any
non-alphanumeric characters which are syntactically significant to
r.mapcalc, then it must be quoted.

[1] This includes incomplete floating-point values such as "1.2e"; in
order to produce reasonable error messages, the token grammar includes
a rule which specifically matches such cases.

The substitutions in the mapcalc() function are direct textual
substitutions performed within Python before the resulting string is
passed to r.mapcalc, so the above needs quotes around $input in order
to correctly handle "unusual" map names.

This is probably the case for most such calls, except those where the
map name is dictated by the script.

I suppose that it would be possible to have the mapcalc() function
automatically add quotes to any arguments which are strings. However,
this would break scripts which pass option values directly to
mapcalc() without parsing them to an int/float first. It would also
preclude cases such as:

  grass.mapcalc("$outmap = $func($inmap)", func = 'sqrt', ...)

unless we add yet more complexity (e.g. names ending in "_raw" aren't
quoted, or similar).

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