<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    the docs have moved (but apparently Google hasn't figured that out
    yet?) GDALRasterBand is now <a moz-do-not-send="true"
href="https://gdal.org/api/gdalrasterband_cpp.html#classGDALRasterBand_1ad80cecc562fd48f5783677de625360ac">here</a>.<br>
    <br>
    Anyway, as you've figured out, the GDALRasterBand object is the
    heart of the matter. You have two ways to read the data, either with
    the RasterIO method or the ReadBlock method. <br>
    If your dataset is small enough to read into available memory,
    RasterIO is probably easier to use. ReadBlock can be more efficient,
    but your code has to handle the offsets for the origin of the block.
    <br>
    <br>
    The code example said to be in ReadBlock seems to have disappeared
    in the migration of the docs. Here's what it contained:<br>
    <br>
    <blockquote>The following code would efficiently compute a histogram
      of eight bit raster data. Note that the final block may be partial
      ... data beyond the edge of the underlying raster band in these
      edge blocks is of an undermined value.
      <p> </p>
      <pre> CPLErr GetHistogram( GDALRasterBand *poBand, int *panHistogram )</pre>
      <p> </p>
      <pre> {
     int        nXBlocks, nYBlocks, nXBlockSize, nYBlockSize;
     int        iXBlock, iYBlock;
     GByte      *pabyData;</pre>
      <p> </p>
      <pre>     memset( panHistogram, 0, sizeof(int) * 256 );</pre>
      <p> </p>
      <pre>     CPLAssert( poBand-><a class="el" title="Fetch the pixel data type for this band." moz-do-not-send="true">GetRasterDataType()</a> == GDT_Byte );</pre>
      <p> </p>
      <pre>     poBand->GetBlockSize( &nXBlockSize, &nYBlockSize );
     nXBlocks = (poBand-><a class="el" title="Fetch XSize of raster." moz-do-not-send="true">GetXSize()</a> + nXBlockSize - 1) / nXBlockSize;
     nYBlocks = (poBand-><a class="el" title="Fetch YSize of raster." moz-do-not-send="true">GetYSize()</a> + nYBlockSize - 1) / nYBlockSize;</pre>
      <p> </p>
      <pre>     pabyData = (GByte *) CPLMalloc(nXBlockSize * nYBlockSize);</pre>
      <p> </p>
      <pre>     for( iYBlock = 0; iYBlock < nYBlocks; iYBlock++ )
     {
         for( iXBlock = 0; iXBlock < nXBlocks; iXBlock++ )
         {
             int        nXValid, nYValid;</pre>
      <p> </p>
      <pre>             poBand->ReadBlock( iXBlock, iYBlock, pabyData );</pre>
      <p> </p>
      <pre>             // Compute the portion of the block that is valid
             // for partial edge blocks.
             if( (iXBlock+1) * nXBlockSize > poBand-><a class="el" title="Fetch XSize of raster." moz-do-not-send="true">GetXSize()</a> )
                 nXValid = poBand-><a class="el" title="Fetch XSize of raster." moz-do-not-send="true">GetXSize()</a> - iXBlock * nXBlockSize;
             else
                 nXValid = nXBlockSize;</pre>
      <p> </p>
      <pre>             if( (iYBlock+1) * nYBlockSize > poBand-><a class="el" title="Fetch YSize of raster." moz-do-not-send="true">GetYSize()</a> )
                 nYValid = poBand-><a class="el" title="Fetch YSize of raster." moz-do-not-send="true">GetYSize()</a> - iYBlock * nYBlockSize;
             else
                 nYValid = nYBlockSize;</pre>
      <p> </p>
      <pre>             // Collect the histogram counts.
             for( int iY = 0; iY < nYValid; iY++ )
             {
                 for( int iX = 0; iX < nXValid; iX++ )
                 {
                     panHistogram[pabyData[iX + iY * nXBlockSize]] += 1;
                 }
             }
         }
     }
 }</pre>
    </blockquote>
    <br>
  </body>
</html>