[GRASS-dev] bug in v.surf.bspline?

Roberto,

I tried out the update to v.surf.bspline and now I CAN do an interpolation
using a vector attribute column.

However, when I use a z-value for interpolation and then use an attribute
column for exactly the same values, I get very different interpolations.

For example, I ran the following two interpolations, the first using the
z-value (layer 0) and the second using the attribute column that is used for
the z-value (layer 1)

v.surf.bspline input=solutrean_age3D@PERMANENT raster=test_interpolation_z
sie=4 sin=4 type=bicubic lambda_i=1 layer=0

v.surf.bspline input=solutrean_age3D@PERMANENT
raster=test_interpolation_attr sie=4 sin=4 type=bicubic lambda_i=1 layer=1
column=CAL_MID

Then I made a difference map of the two results

r.mapcalc 'test_interpolation_diff=test_interpolation_z -
test_interpolation_attr'

Finally, I ran r.univar to summarize the differences. As you can see there
is a big difference between the 2 maps.

GRASS 6.3.cvs (Europe_ll_wgs84):~ > r.univar test_interpolation_diff
100%
total null and non-null cells: 21758946
total null cells: 0

Of the non-null cells:
----------------------
n: 21758946
minimum: 280.434
maximum: 24343.5
range: 24063.1
mean: 6819.02
mean of absolute values: 6819.02
standard deviation: 5566.97
variance: 3.09912e+07
variation coefficient: 81.6389 %
sum: 148374632036.5238342285

I'm not sure which is the more accurate, but it LOOKS like the one using
z-values is the correct one. I made a jpg output from each map and attach
them here for visual comparison. It is clear that they are very different,
even though ostensibly using the same data.

Also, in both cases the interpolation does not respect a MASK.

I like this module a lot and hope that this can help to improve it.

Michael

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On 10/19/07 9:35 AM, "Michael Barton" <michael.barton@asu.edu> wrote:

Excellent! Thanks again.

Michael

On 10/19/07 9:34 AM, "Roberto Antolin" <roberto@geomatica.como.polimi.it>
wrote:

Hello Michael

Michael Barton escribió:

Thanks Roberto. Is it in the CVS now?

Yes, it is. Sorry, I forgot to tell you :slight_smile:
Please, let me now if it is ok or there is still something wrong.

Roberto.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

(attachments)

test_interpolation_attr.jpg
test_interpolation_z.jpg

Michael Barton wrote:

Also, in both cases the interpolation does not respect a MASK.

It is not expected to. The MASK is put into action only when *reading* a raster
map, not when creating/writing one.

e.g.
r.mapcalc MASK=fields
r.mapcalc one=1
g.remove MASK
r.univar one
# look, no NULL cells

r.mapcalc MASK=fields
r.mapcalc one_masked=one
g.remove MASK
r.univar one_masked
# lots of null cells, as the "one" map was masked while being read

If you don't remove MASK, r.univar (libgis) adds in nulls when it reads the
maps.

Hamish

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

OK. I see. Because r.surf.bspline is reading a vector, rather than a raster,
it doesn't respect a mask.

...but it would be nice if it did, at least optionally.

Michael

On 10/21/07 4:31 PM, "Hamish" <hamish_nospam@yahoo.com> wrote:

Michael Barton wrote:

Also, in both cases the interpolation does not respect a MASK.

It is not expected to. The MASK is put into action only when *reading* a
raster
map, not when creating/writing one.

e.g.
r.mapcalc MASK=fields
r.mapcalc one=1
g.remove MASK
r.univar one
# look, no NULL cells

r.mapcalc MASK=fields
r.mapcalc one_masked=one
g.remove MASK
r.univar one_masked
# lots of null cells, as the "one" map was masked while being read

If you don't remove MASK, r.univar (libgis) adds in nulls when it reads the
maps.

Hamish

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Hi Michael and all,

Michael Barton escribió:

Roberto,
However, when I use a z-value for interpolation and then use an attribute
column for exactly the same values, I get very different interpolations.

Oh my gosh! What a mess generated by only one letter!! It was a problem with integer attribute values. I think it is correctly fixed now. I don't think so, but maybe the interpolations are still slightly different. Anyway, they shouldn't be as different as before.

Please, let me know.

I like this module a lot and hope that this can help to improve it.

Thank you Michael! All your help is welcome. I like this module too and I like to improve it.

Regards,
Roberto.

--
Roberto Antolín Sánchez
Politecnico di Milano - Polo Regionale di Como
(Laboratorio di Geomatica V2.8)
Via Valleggio, 11 - 22100 Como, Italy
tel: +39 031 332 7533 || fax: +39 031 332 7519
roberto@geomatica.como.polimi.it

On 10/22/07 1:55 AM, "Roberto Antolin" <roberto@geomatica.como.polimi.it>
wrote:

Hi Michael and all,

Michael Barton escribió:

Roberto,
However, when I use a z-value for interpolation and then use an attribute
column for exactly the same values, I get very different interpolations.

Oh my gosh! What a mess generated by only one letter!! It was a problem
with integer attribute values. I think it is correctly fixed now. I
don't think so, but maybe the interpolations are still slightly
different. Anyway, they shouldn't be as different as before.

Shouldn't the results be identical if the values used for interpolation are
identical, regardless of whether they reside in the z-coordinate or an
attribute?

Please, let me know.

I'll test as soon as I have a chance and let you know.

Michael

I like this module a lot and hope that this can help to improve it.

Thank you Michael! All your help is welcome. I like this module too and
I like to improve it.

Regards,
Roberto.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On Mon, 22 Oct 2007, Michael Barton wrote:

Shouldn't the results be identical if the values used for interpolation are
identical, regardless of whether they reside in the z-coordinate or an
attribute?

Yes, the results must be the same, but only if there isn't another bug. I'm completly sure about z-coord interpolation cos I use it daily. However, since I don't use it with attributes values I don't know if it works properly well. It should do so because the interpolation functions are the same in both cases.

Obviously it works well to me, otherwise, I wouldn't have done the update to cvs. However, till you don't do this last test I can't be sure. That was what I wanted to mean, some caution. Sorry if I created some doubts. It was no my intention.

I'll test as soon as I have a chance and let you know.

Thank you very much, Michael. You are helping a lot for the module bugfixing.

Roberto.

OK. I'm relieved. I'll get it tested in the next day or two. Thanks again
for such a very fast response to my query.

Michael

On 10/22/07 11:55 AM, "Roberto Antolín" <roberto@geomatica.como.polimi.it>
wrote:

On Mon, 22 Oct 2007, Michael Barton wrote:

Shouldn't the results be identical if the values used for interpolation are
identical, regardless of whether they reside in the z-coordinate or an
attribute?

Yes, the results must be the same, but only if there isn't another bug.
I'm completly sure about z-coord interpolation cos I use it daily.
However, since I don't use it with attributes values I don't know if it
works properly well. It should do so because the interpolation functions
are the same in both cases.

Obviously it works well to me, otherwise, I wouldn't have done the update
to cvs. However, till you don't do this last test I can't be sure. That
was what I wanted to mean, some caution. Sorry if I created some doubts.
It was no my intention.

I'll test as soon as I have a chance and let you know.

Thank you very much, Michael. You are helping a lot for the module
bugfixing.

Roberto.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Roberto,

I was able to test your fix of v.surf.bspline to use a vector attribute
table value for interpolation.

AFAICT, it works perfectly. As before, I did an interpolation of an
attribute value (using bicubic) that is exactly the same as the z value.
Then I did a difference map. They are identical, creating a 0 value
difference map.

Thanks again for the very quick response to my bug report.

Michael

On 10/22/07 11:55 AM, "Roberto Antolín" <roberto@geomatica.como.polimi.it>
wrote:

On Mon, 22 Oct 2007, Michael Barton wrote:

Shouldn't the results be identical if the values used for interpolation are
identical, regardless of whether they reside in the z-coordinate or an
attribute?

Yes, the results must be the same, but only if there isn't another bug.
I'm completly sure about z-coord interpolation cos I use it daily.
However, since I don't use it with attributes values I don't know if it
works properly well. It should do so because the interpolation functions
are the same in both cases.

Obviously it works well to me, otherwise, I wouldn't have done the update
to cvs. However, till you don't do this last test I can't be sure. That
was what I wanted to mean, some caution. Sorry if I created some doubts.
It was no my intention.

I'll test as soon as I have a chance and let you know.

Thank you very much, Michael. You are helping a lot for the module
bugfixing.

Roberto.

__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

Hi Michael and all,

Michael Barton escribió:

Roberto,
AFAICT, it works perfectly. As before, I did an interpolation of an
attribute value (using bicubic) that is exactly the same as the z value.
Then I did a difference map. They are identical, creating a 0 value
difference map.

Awesome!!

Thanks again for the very quick response to my bug report.

Welcome, but I think I had to do it :slight_smile:
Thanks to you for your help on the bugfix.

Roberto.

--
Roberto Antolín Sánchez
Politecnico di Milano - Polo Regionale di Como
(Laboratorio di Geomatica V2.8)
Via Valleggio, 11 - 22100 Como, Italy
tel: +39 031 332 7533 || fax: +39 031 332 7519
roberto@geomatica.como.polimi.it