[GRASS-dev] [GRASS GIS] #771: use longer ints for counting raster cells

GRASS GIS trac at osgeo.org
Thu Oct 1 10:03:06 EDT 2009

#771: use longer ints for counting raster cells
 Reporter:  hamish       |       Owner:  grass-dev at lists.osgeo.org
     Type:  task         |      Status:  new                      
 Priority:  normal       |   Milestone:  6.4.0                    
Component:  Raster       |     Version:  svn-develbranch6         
 Keywords:  overflow     |    Platform:  All                      
      Cpu:  Unspecified  |  

 when region sizes exceed a bit more than 45000x45000 plain int no longer
 has the bitspace to keep track of the number of cells and overflows.
 'unsigned int' only buys us a little time until region size exceeds

 in these cases 'unsigned long long' could be used to make the size bigger.
 not all compilers know about long long though so ./configure does a check
 for it and sets a macro.

  * r.stats and r.univar are a priority here.

 r.info and g.region seem to have working implimentations,

 example code from 6.5's g.region:

             fprintf(stdout, "%-*s %lld\n", width, "cells:",
                     (long long)window->rows * window->cols);
             if (print_flag & PRINT_3D)
                 fprintf(stdout, "%-*s %lld\n", width, "3dcells:",
                         (long long)window->rows3 * window->cols3 *
             fprintf(stdout, "%-*s %ld\n", width, "cells:",
                     (long)window->rows * window->cols);
             if (print_flag & PRINT_3D)
                 fprintf(stdout, "%-*s %ld\n", width, "3dcells:",
                         (long)window->rows3 * window->cols3 *

             compose_line(out, "  Total Cells:  %llu",
                          (unsigned long long)cellhd.rows * cellhd.cols);
                          "  Total Cells:  %lu (accuracy - see r.info
                          (unsigned long)cellhd.rows * cellhd.cols);

 r.info man page:
 Some standards (ISO-C90) and compilers do not support the 'long long' type
 as a 64-bit type. In the case that GRASS was built with such a compiler,
 an accuracy message may be displayed in the output of <em>r.info</em>
 after Total Cells:

 we should standardize on something. any reason not to make it unsigned?



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

More information about the grass-dev mailing list