[GRASS5] Re: [bug #3023] (grass) r.fillnulls doesn't work

From: "Hamish via RT" <grass-bugs@intevation.de>

r.fillnulls fails in such a way:

GRASS 6.0.cvs:~ > r.fillnulls input=N51E016_nowy
output=N51E016_nowy.fld Using tmp file r_fillnulls_4707
Locating and isolating NULL areas...
100%
r.buffer: 00000000 - illegal distance specification

..

ERROR detected: /usr/local/grass-6.0.cvs/scripts/r.fillnulls
abandoned. Removing temporary map:

..

> .. pretty much everything will be broken after the r.buffer step
> fails. Please try again with the two updated scripts.

As you said...

well at least it fails gracefully now.

hmmm. I've just downloaded the N51E016 SRTM data and r.fillnulls
works fine for me.

Lat/lon location, right?
GRASS> g.proj -p

yes:
GRASS 6.0.cvs:~ > g.region -p
projection: 3 (Latitude-Longitude)
zone: 0
datum: wgs84
ellipsoid: wgs84
north: 52:00:01.5N
south: 50:59:58.5N
west: 15:59:58.5E
east: 17:00:01.5E
nsres: 0:00:03
ewres: 0:00:03
rows: 1201
cols: 1201

what do you get if you type this at a command prompt:

echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
00000000 or 0.60000000 ?

Neither:

GRASS 6.0.cvs:~ > echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
0,00000000

"," instead of "." - would that be the issue? I Poland, in opposite to the normal world, we use the coma as the decimal point deliminator. Does r.fillnulls rely on local system settings?

Maciek

>> r.fillnulls fails in such a way:
>>
>> GRASS 6.0.cvs:~ > r.fillnulls input=N51E016_nowy
>> output=N51E016_nowy.fld Using tmp file r_fillnulls_4707
>> Locating and isolating NULL areas...
>> 100%
>> r.buffer: 00000000 - illegal distance specification
>

..

> what do you get if you type this at a command prompt:
>
> echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
> 00000000 or 0.60000000 ?

Neither:

GRASS 6.0.cvs:~ > echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
0,00000000

"," instead of "." - would that be the issue? I Poland, in opposite to
the normal world, we use the coma as the decimal point deliminator.
Does r.fillnulls rely on local system settings?

Yes, that's the problem.

I think awk might have troubles too. does this give "0,6":
echo "0,3 0,3" | awk '{printf "%.8f\n", ($1 + $2)}'
?

We can't assume "bc" or "dc" are installed, but come to think of it we
are using an arbitrary buffer distance here anyway so it doesn't really
matter if we are +/- 1m. I've just applied a fix in CVS removing the
above "awk" step. please test.

Hamish

Hm, I've been half-paying attention to this, but I have a possible solution to this. A while back I modified the r.fillnulls because I wanted more than 1 cell buffer and to add a couple options to control the v.surf.rst. I had trouble with the way it was done then (can't remember the details) and switched to using r.grow. It becomes simpler since you don't need to think about how big a cell is, or in this case how the decimal is represented, and it only needs 1 temp raster. That whole block to generate the MASK condenses down to 2 lines:

r.mapcalc $TMP1="if(isnull($GIS_OPT_input),1,null())"
r.grow input=$TMP1 output=MASK rad=1

hope this helps.

On Mar 1, 2005, at 8:24 PM, Hamish wrote:

r.fillnulls fails in such a way:

GRASS 6.0.cvs:~ > r.fillnulls input=N51E016_nowy
output=N51E016_nowy.fld Using tmp file r_fillnulls_4707
Locating and isolating NULL areas...
100%
r.buffer: 00000000 - illegal distance specification

..

what do you get if you type this at a command prompt:

echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
00000000 or 0.60000000 ?

Neither:

GRASS 6.0.cvs:~ > echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
0,00000000

"," instead of "." - would that be the issue? I Poland, in opposite to
the normal world, we use the coma as the decimal point deliminator.
Does r.fillnulls rely on local system settings?

Yes, that's the problem.

I think awk might have troubles too. does this give "0,6":
echo "0,3 0,3" | awk '{printf "%.8f\n", ($1 + $2)}'
?

We can't assume "bc" or "dc" are installed, but come to think of it we
are using an arbitrary buffer distance here anyway so it doesn't really
matter if we are +/- 1m. I've just applied a fix in CVS removing the
above "awk" step. please test.

Hamish

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

-----
William Kyngesburye <kyngchaos@charter.net>
http://webpages.charter.net/kyngchaos/

Theory of the Universe

There is a theory which states that if ever anyone discovers exactly what the universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarrely inexplicable. There is another theory which states that this has already happened.

-Hitchhiker's Guide to the Galaxy 2nd season intro

Hamish wrote:

> >> r.fillnulls fails in such a way:
> >>
> >> GRASS 6.0.cvs:~ > r.fillnulls input=N51E016_nowy
> >> output=N51E016_nowy.fld Using tmp file r_fillnulls_4707
> >> Locating and isolating NULL areas...
> >> 100%
> >> r.buffer: 00000000 - illegal distance specification
> >
..
> > what do you get if you type this at a command prompt:
> >
> > echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
> > 00000000 or 0.60000000 ?
>
> Neither:
>
> GRASS 6.0.cvs:~ > echo "0.3 0.3" | awk '{printf "%.8f\n", ($1 + $2)}'
> 0,00000000
>
> "," instead of "." - would that be the issue? I Poland, in opposite to
> the normal world, we use the coma as the decimal point deliminator.
> Does r.fillnulls rely on local system settings?

Yes, that's the problem.

I think awk might have troubles too. does this give "0,6":
echo "0,3 0,3" | awk '{printf "%.8f\n", ($1 + $2)}'
?

We can't assume "bc" or "dc" are installed, but come to think of it we
are using an arbitrary buffer distance here anyway so it doesn't really
matter if we are +/- 1m. I've just applied a fix in CVS removing the
above "awk" step. please test.

Hmm. In that case, scripts which use awk should probably have:

  LC_NUMERIC=C
  export LC_NUMERIC

Or just:

  LC_NUMERIC=C awk ...

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