[GRASS-user] r.resamp.rst Producing Bad Values

I'm trying to clean up a noisy data set using r.resamp.rst.
I used the following procedure successfully:

tcurv30 is a tangential curvature map generated by r.slope.aspect from the
data, at 30 meter resolution.

tsmooth30 = abs(tcurv30) * 500
(r.resamp.rst does not accept negative smoothing values)

Range of data in tsmooth30: min = 0.000000 max = 8.164329

(history) generated by r.resamp.rst
tension=213.504205, smoothing=tsmooth30
dnorm=374.699880, zmult=1.000000
KMAX=50, KMIN=35, errtotal=0.289533
zmin_data=450.160004, zmax_data=500.000000
zmin_int=450.592767, zmax_int=500.449846

The tension was set to 40, and the map was resampled to 10m resolution.
So far, so good.

Now I would like to run a similar procedure on the 10m data map, but without
changing the resolution:

tcurv10 is a tangential curvature map generated by r.slope.aspect from the
resampled and smoothed data, at 10 meter resolution.

tsmooth10 = abs(tcurv10) * 500

Range of data in tsmooth10: min = 0.000000 max = 23.222006

(history) generated by r.resamp.rst
tension=320.256308, smoothing=tsmooth10
dnorm=124.899960, zmult=1.000000
KMAX=50, KMIN=35, errtotal=nan
zmin_data=450.592773, zmax_data=500.449860
zmin_int=nan, zmax_int=nan

(Again, the tension was set to 40)

The "nan" values appear in an unbroken band around the perimeter of the
region, 6 to 8 cells wide. It should be noted that all the data is well
inside the perimeter, so the portion of the smoothing map which seems to be
causing the trouble consists entirely of zero values. The rest of the map,
which includes all of the data, appears to have been correctly processed.

This problem does not occur if I use constant-value smoothing maps. I tried
both zero and nonzero (1 and 10) constant values.

I tried changing the tsmooth10 map to:

tsmooth10 = max( 1, abs(tcurv10) * 500 )

And to:

tsmooth10 = abs(tcurv10) * 250

I tried changing the output resolution in r.resamp.rst to 5m.

The problem still occurs in all cases. I would simply work around it, but
r.mapcalc will not replace "nan" values. I am out of ideas. Any suggestions?

--
Carl Brown
Whitefield, NH USA

Carl Brown wrote:

The problem still occurs in all cases. I would simply work around it, but
r.mapcalc will not replace "nan" values. I am out of ideas. Any suggestions?

will r.null replace "nan" values? If not, we should probably add a flag to
r.null to allow that. r.in.xyz can create nan values when using the coeff_var
method*, for unknown reasons. In the man page I say to use r.null to fix it but
I'm not totally convinced that actually works.

[*] coeff_var is 100 * stdev / mean. So nan when data in bin is all 0s?

Hamish

____________________________________________________________________________________
Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=list&sid=396545433

Hamish wrote:

> The problem still occurs in all cases. I would simply work around it, but
> r.mapcalc will not replace "nan" values. I am out of ideas. Any suggestions?

will r.null replace "nan" values? If not, we should probably add a flag to
r.null to allow that.

We should look into changing G_is_[fd]_null_value() to test for any
NaN value, rather than for the specific bit patterns which GRASS uses.

If we have isnan() (C99), we can use that. For IEEE-754, NaN has an
all-ones exponent and a non-zero mantissa. Testing for x!=x may also
work.

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

On Thursday 06 September 2007, Hamish wrote:

will r.null replace "nan" values?

Not in this case, at least.

But I did find a workaround using r.mapcalc:
(data= map with nan values)

test = round ( data ) # This transforms nans into nulls
fixed = if ( isnull ( test ), 0, data )

--
Carl Brown
Whitefield, NH USA

Carl Brown wrote:

> will r.null replace "nan" values?

Not in this case, at least.

But I did find a workaround using r.mapcalc:
(data= map with nan values)

test = round ( data ) # This transforms nans into nulls
fixed = if ( isnull ( test ), 0, data )

How about:

  fixed = if(data == data, data, null())
?

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