[GRASS-dev] [GRASS GIS] #475: r.stats: last bin always has a single cell

GRASS GIS trac at osgeo.org
Tue Feb 3 18:25:31 EST 2009


#475: r.stats: last bin always has a single cell
----------------------+-----------------------------------------------------
 Reporter:  hamish    |       Owner:  grass-dev at lists.osgeo.org
     Type:  defect    |      Status:  new                      
 Priority:  critical  |   Milestone:  6.4.0                    
Component:  Raster    |     Version:  svn-develbranch6         
 Keywords:  r.stats   |    Platform:  All                      
      Cpu:  All       |  
----------------------+-----------------------------------------------------
 Hi, r.stats seems to be doing something funny: the last bin always
 contains only one cell. Same result with GRASS 5.4.1 - 6.5svn on
 Linux, OSX, Solaris.

 speafish:
 {{{
 G65> g.region rast=elevation.10m
 G65> r.stats elevation.10m nsteps=10 -c | nl
  100%
      1  1061.064087-1139.632019 243490
      2  1139.632019-1218.199951 732066
      3  1218.199951-1296.767883 399213
      4  1296.767883-1375.335815 351601
      5  1375.335815-1453.903748 315246
      6  1453.903748-1532.47168 265487
      7  1532.47168-1611.039612 216796
      8  1611.039612-1689.607544 115175
      9  1689.607544-1768.175476 15727
     10  1768.175476-1846.743408 1

 G65> r.mapcalc 'bin10 = if(elevation.10m > 1768.175476, 1, null() )'
 G65> r.univar bin10 | grep '^n'
 n: 12344
 }}}

 other bin counts don't line up either:
 {{{
 G65> r.mapcalc 'bin2 = if(elevation.10m > 1139.632019 && elevation.10m <
 1218.199951, 1, null() )'
 G65> r.univar bin2 | grep '^n'
 n: 645823

 G65> r.mapcalc 'bin9 = if(elevation.10m > 1689.607544 && elevation.10m <
 1768.175476, 1, null() )'
 G65> r.univar bin9 | grep '^n'
 n: 87599
 }}}

 all-in-one bin gives correct result:
 {{{
 r.stats elevation.10m nsteps=1 -c
  100%
 1061.064087-1846.743408 2654802

 r.univar elevation.10m | grep '^n'
 n: 2654802

 # but,
 r.stats elevation.10m nsteps=2 -c
  100%
 1061.064087-1453.903748 2654801
 1453.903748-1846.743408 1
 }}}

 sum total seems to be ok, just distribution does not match reported range:
 {{{
 r.stats elevation.10m nsteps=5 -c
  100%
 1061.064087-1218.199951 1090464
 1218.199951-1375.335815 817890
 1375.335815-1532.47168 573165
 1532.47168-1689.607544 173282
 1689.607544-1846.743408 1

 echo $((1090464 + 817890 + 573165 + 173282 + 1))
 2654802
 }}}


 thanks to Doc Robinson for reporting this.

 (I have a vague memory that this was also reported years ago in the
 mailing list archives??)


 thanks,
 Hamish

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/475>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list