[GRASS-dev] [GRASS GIS] #2820: v.surf.idw results seem seriously wrong and don't match r.surf.idw results

GRASS GIS trac at osgeo.org
Thu Dec 17 14:32:52 PST 2015


#2820: v.surf.idw results seem seriously wrong and don't match r.surf.idw results
----------------------+-------------------------------------------------
  Reporter:  lrntct   |      Owner:  grass-dev@…
      Type:  defect   |     Status:  new
  Priority:  blocker  |  Milestone:  7.0.3
 Component:  Vector   |    Version:  7.0.1
Resolution:           |   Keywords:  v.surf.idw r.surf.idw interpolation
       CPU:  x86-64   |   Platform:  Linux
----------------------+-------------------------------------------------

Comment (by mlennert):

 Investigating further. Adding the following patch for diagnosis (in
 addition to the above sqrt patch):


 {{{
 Index: main.c
 ===================================================================
 --- main.c      (révision 67166)
 +++ main.c      (copie de travail)
 @@ -386,6 +386,7 @@
                 sum1 = 0.0;
                 sum2 = 0.0;
                 for (n = 0; n < nsearch; n++) {
 +                   fprintf(stdout, "%f,%f,%f,%f\n", east, north,
 list[n].dist, list[n].z);
                     if ((dist = list[n].dist)) {
                         sum1 += list[n].z / pow(dist, p);
                         sum2 += 1.0 / pow(dist, p);
 }}}

 and then running the following commands (i.e. creating one vector point
 and getting distance and annual precipitation values from the 12 nearest
 stations to that point, as well as the same values for the equivalent
 pixel in both runs of v.surf.idw (without and with -n flag):


 {{{
 g.region vect=nc_state res=500 -ap
 echo "567250|214750" | v.in.ascii in=- out=center --o
 v.distance -ap from=center to=precip_30ynormals up=dist,to_attr
 to_col=annual dmax=64000 --q | tail -n -12
 v.surf.idw precip_30ynormals col=annual out=vsurfidw --o > list.csv
 v.surf.idw -n precip_30ynormals col=annual out=vsurfidw_noindex --o >
 list.csv
 grep "567250.000000,214750" list.csv > list_center.csv
 grep "567250.000000,214750" list_noindex.csv > list_center_noindex.csv
 }}}

 and putting together the results of the v.distance, v.surf.idw and
 v.surf.idw -n runs, I get (results ordered by increasing distance):

 * v.distance


 {{{
 distance                value
 8400,5853273955         1224,28
 33001,5791065737        1183,64
 33543,2163702733        1183,64
 39603,9217121153        1234,44
 41429,8528851821        1158,24
 41667,8156183992        1206,5
 41677,4928801831        1143
 42993,6439600215        1209,04
 55288,6854942564        1170,94
 58543,7865733219        1216,66
 60471,6142897           1219,2
 62763,095429678         1094,74
 }}}


 * v.surf.idw


 {{{
 distance        value
 80047,835648    1191,26
 90264,15377     1183,64
 91013,285596    1158,24
 99493,013889    1219,2
 120304,207816   1120,14
 171007,225542   1358,9
 183102,228906   1440,18
 184179,357051   1170,94
 194397,039723   1234,44
 200403,915046   1163,32
 230189,059243   1546,86
 231312,997387   1259,84
 }}}


 * v.surf.idw -n


 {{{
 8400,585327     1224,28
 33001,579107    1183,64
 33543,21637     1183,64
 39603,921712    1234,44
 41429,852885    1158,24
 41667,815618    1206,5
 41677,49288     1143
 42993,64396     1209,04
 55288,685494    1170,94
 58543,786573    1216,66
 60471,61429     1219,2
 62763,09543     1094,74
 }}}


 In other words, v.surf.idw -n gives the exact same values as v.distance,
 but v.surf.idw without the flag gives a completely different set of
 distances. So, I have the feeling that the issue is in the
 [https://trac.osgeo.org/grass/browser/grass/trunk/vector/v.surf.idw/main.c#L458
 calculate_distances()] function or possibly in the creation of the
 [https://trac.osgeo.org/grass/browser/grass/trunk/vector/v.surf.idw/main.c#L187
 shortlist of cells to look in] in main.c, but I haven't been able to
 pinpoint the culprit, yet.

 Any help is more than welcome.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2820#comment:13>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list