⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classgdalrasterband.html

📁 gdal库的学习文档
💻 HTML
📖 第 1 页 / 共 5 页
字号:
This method is the same as the C <a class="el" href="gdal_8h.html#b0ba355605bdc8ee2e7f18f846c1078c">GDALReadBlock()</a> function.<p>See the <a class="el" href="classGDALRasterBand.html#58aae254f551f0bbc7f04d816af6cea2">GetLockedBlockRef()</a> method for a way of accessing internally cached block oriented data without an extra copy into an application buffer.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>nXBlockOff</em>&nbsp;</td><td>the horizontal block offset, with zero indicating the left most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>nYBlockOff</em>&nbsp;</td><td>the vertical block offset, with zero indicating the left most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>pImage</em>&nbsp;</td><td>the buffer into which the data will be read. The buffer must be large enough to hold GetBlockXSize()*GetBlockYSize() words of type <a class="el" href="classGDALRasterBand.html#e3ec3bfe18258dd73db3911fed97cc2e">GetRasterDataType()</a>.</td></tr>  </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>CE_None on success or CE_Failure on an error.</dd></dl>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><pre> CPLErr GetHistogram( GDALRasterBand *poBand, int *panHistogram )</pre><p><pre> {     int        nXBlocks, nYBlocks, nXBlockSize, nYBlockSize;     int        iXBlock, iYBlock;     GByte      *pabyData;</pre><p><pre>     memset( panHistogram, 0, sizeof(int) * 256 );</pre><p><pre>     CPLAssert( poBand-&gt;<a class="el" href="classGDALRasterBand.html#e3ec3bfe18258dd73db3911fed97cc2e">GetRasterDataType()</a> == GDT_Byte );</pre><p><pre>     poBand-&gt;GetBlockSize( &amp;nXBlockSize, &amp;nYBlockSize );     nXBlocks = (poBand-&gt;<a class="el" href="classGDALRasterBand.html#46f78e79da622039a670107ae5a94f02">GetXSize()</a> + nXBlockSize - 1) / nXBlockSize;     nYBlocks = (poBand-&gt;<a class="el" href="classGDALRasterBand.html#dd1efe50e7486e7a5623eadd8f06b49b">GetYSize()</a> + nYBlockSize - 1) / nYBlockSize;</pre><p><pre>     pabyData = (GByte *) CPLMalloc(nXBlockSize * nYBlockSize);</pre><p><pre>     for( iYBlock = 0; iYBlock &lt; nYBlocks; iYBlock++ )     {         for( iXBlock = 0; iXBlock &lt; nXBlocks; iXBlock++ )         {             int        nXValid, nYValid;</pre><p><pre>             poBand-&gt;ReadBlock( iXBlock, iYBlock, pabyData );</pre><p><pre>             // Compute the portion of the block that is valid             // for partial edge blocks.             if( (iXBlock+1) * nXBlockSize &gt; poBand-&gt;<a class="el" href="classGDALRasterBand.html#46f78e79da622039a670107ae5a94f02">GetXSize()</a> )                 nXValid = poBand-&gt;<a class="el" href="classGDALRasterBand.html#46f78e79da622039a670107ae5a94f02">GetXSize()</a> - iXBlock * nXBlockSize;             else                 nXValid = nXBlockSize;</pre><p><pre>             if( (iYBlock+1) * nYBlockSize &gt; poBand-&gt;<a class="el" href="classGDALRasterBand.html#dd1efe50e7486e7a5623eadd8f06b49b">GetYSize()</a> )                 nYValid = poBand-&gt;<a class="el" href="classGDALRasterBand.html#dd1efe50e7486e7a5623eadd8f06b49b">GetYSize()</a> - iYBlock * nYBlockSize;             else                 nYValid = nYBlockSize;</pre><p><pre>             // Collect the histogram counts.             for( int iY = 0; iY &lt; nYValid; iY++ )             {                 for( int iX = 0; iX &lt; nXValid; iX++ )                 {                     panHistogram[pabyData[iX + iY * nXBlockSize]] += 1;                 }             }         }     } }</pre><p><pre></pre> </div></div><p><a class="anchor" name="e92a432b3fe9ec0403e692af611095c9"></a><!-- doxytag: member="GDALRasterBand::WriteBlock" ref="e92a432b3fe9ec0403e692af611095c9" args="(int, int, void *)" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname">CPLErr GDALRasterBand::WriteBlock           </td>          <td>(</td>          <td class="paramtype">int&nbsp;</td>          <td class="paramname"> <em>nXBlockOff</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">int&nbsp;</td>          <td class="paramname"> <em>nYBlockOff</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">void *&nbsp;</td>          <td class="paramname"> <em>pImage</em></td><td>&nbsp;</td>        </tr>        <tr>          <td></td>          <td>)</td>          <td></td><td></td><td width="100%"></td>        </tr>      </table></div><div class="memdoc"><p>Write a block of image data efficiently.<p>This method accesses a "natural" block from the raster band without resampling, or data type conversion. For a more generalized, but potentially less efficient access use <a class="el" href="classGDALRasterBand.html#5497e8d29e743ee9177202cb3f61c3c7">RasterIO()</a>.<p>This method is the same as the C <a class="el" href="gdal_8h.html#0719b0e30b9fd9bcbd40dbacf682e244">GDALWriteBlock()</a> function.<p>See <a class="el" href="classGDALRasterBand.html#09e1d83971ddff0b43deffd54ef25eef">ReadBlock()</a> for an example of block oriented data access.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>nXBlockOff</em>&nbsp;</td><td>the horizontal block offset, with zero indicating the left most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>nYBlockOff</em>&nbsp;</td><td>the vertical block offset, with zero indicating the left most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>pImage</em>&nbsp;</td><td>the buffer from which the data will be written. The buffer must be large enough to hold GetBlockXSize()*GetBlockYSize() words of type <a class="el" href="classGDALRasterBand.html#e3ec3bfe18258dd73db3911fed97cc2e">GetRasterDataType()</a>.</td></tr>  </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>CE_None on success or CE_Failure on an error.</dd></dl>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. </div></div><p><a class="anchor" name="58aae254f551f0bbc7f04d816af6cea2"></a><!-- doxytag: member="GDALRasterBand::GetLockedBlockRef" ref="58aae254f551f0bbc7f04d816af6cea2" args="(int nXBlockOff, int nYBlockOff, int bJustInitialize=FALSE)" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname"><a class="el" href="classGDALRasterBlock.html">GDALRasterBlock</a> * GDALRasterBand::GetLockedBlockRef           </td>          <td>(</td>          <td class="paramtype">int&nbsp;</td>          <td class="paramname"> <em>nXBlockOff</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">int&nbsp;</td>          <td class="paramname"> <em>nYBlockOff</em>, </td>        </tr>        <tr>          <td class="paramkey"></td>          <td></td>          <td class="paramtype">int&nbsp;</td>          <td class="paramname"> <em>bJustInitialize</em> = <code>FALSE</code></td><td>&nbsp;</td>        </tr>        <tr>          <td></td>          <td>)</td>          <td></td><td></td><td width="100%"></td>        </tr>      </table></div><div class="memdoc"><p>Fetch a pointer to an internally cached raster block.<p>This method will returned the requested block (locked) if it is already in the block cache for the layer. If not, the block will be read from the driver, and placed in the layer block cached, then returned. If an error occurs reading the block from the driver, a NULL value will be returned.<p>If a non-NULL value is returned, then a lock for the block will have been acquired on behalf of the caller. It is absolutely imperative that the caller release this lock (with GDALRasterBlock::DropLock()) or else severe problems may result.<p>Note that calling <a class="el" href="classGDALRasterBand.html#58aae254f551f0bbc7f04d816af6cea2">GetLockedBlockRef()</a> on a previously uncached band will enable caching.<p><dl compact><dt><b>Parameters:</b></dt><dd>  <table border="0" cellspacing="2" cellpadding="0">    <tr><td valign="top"></td><td valign="top"><em>nBlockXOff</em>&nbsp;</td><td>the horizontal block offset, with zero indicating the left most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>nYBlockOff</em>&nbsp;</td><td>the vertical block offset, with zero indicating the top most block, 1 the next block and so forth.</td></tr>    <tr><td valign="top"></td><td valign="top"><em>bJustInitialize</em>&nbsp;</td><td>If TRUE the block will be allocated and initialized, but not actually read from the source. This is useful when it will just be completely set and written back.</td></tr>  </table></dl><dl class="return" compact><dt><b>Returns:</b></dt><dd>pointer to the block object, or NULL on failure. </dd></dl></div></div><p><a class="anchor" name="dd295111c2227df72425c3a499dd0279"></a><!-- doxytag: member="GDALRasterBand::FlushCache" ref="dd295111c2227df72425c3a499dd0279" args="()" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname">CPLErr GDALRasterBand::FlushCache           </td>          <td>(</td>          <td class="paramtype">void&nbsp;</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [virtual]</code></td>        </tr>      </table></div><div class="memdoc"><p>Flush raster data cache.<p>This call will recover memory used to cache data blocks for this raster band, and ensure that new requests are referred to the underlying driver.<p>This method is the same as the C function <a class="el" href="gdal_8h.html#d19e351b5fc67513ea36bf6a60f1120d">GDALFlushRasterCache()</a>.<p><dl class="return" compact><dt><b>Returns:</b></dt><dd>CE_None on success. </dd></dl></div></div><p><a class="anchor" name="9602a34799a8a9d72f0a7b99e06864a5"></a><!-- doxytag: member="GDALRasterBand::GetCategoryNames" ref="9602a34799a8a9d72f0a7b99e06864a5" args="()" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>          <td class="memname">char ** GDALRasterBand::GetCategoryNames           </td>          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [virtual]</code></td>        </tr>      </table></div><div class="memdoc"><p>Fetch the list of category names for this raster.<p>The return list is a "StringList" in the sense of the CPL functions. That is a NULL terminated array of strings. Raster values without associated names will have an empty string in the returned list. The first entry in the list is for raster values of zero, and so on.<p>The returned stringlist should not be altered or freed by the application. It may change on the next GDAL call, so please copy it if it is needed for any period of time.<p><dl class="return" compact><dt><b>Returns:</b></dt><dd>list of names, or NULL if none. </dd></dl></div></div><p><a class="anchor" name="dcca51d230b5ac848c43f1896293fb50"></a><!-- doxytag: member="GDALRasterBand::GetNoDataValue" ref="dcca51d230b5ac848c43f1896293fb50" args="(int *pbSuccess=NULL)" --><div class="memitem"><div class="memproto">      <table class="memname">        <tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -