<font face="courier new,monospace">James,<br><br>I don't have a lot of time, but I can address some things quickly. Blocksize and raster size are not necessarily the same thing. In some datasets, a block is represented as a tile, in scanline oriented data, it is represented as one scanline, or a row. To obtain the x and y size of the data set, use poDataset->GetRaster[XY]Size(). This should report the values you are looking for. To access all of the data, loop over the scanlines and read in one at a time, or read in the entire raster into one buffer. Hope that helps.<br>
<br>kss<br clear="all"></font><br>/**<br> *<br> * Kyle Shannon<br> * <a href="mailto:ksshannon@gmail.com" target="_blank">ksshannon@gmail.com</a><br> *<br> */<br><br><br>
<br><br><div class="gmail_quote">On Mon, Aug 15, 2011 at 13:09, James Sulzman <span dir="ltr"><<a href="mailto:sulzman@casco.net">sulzman@casco.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal">Hi All,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I could use a little help, and it would be greatly appreciated.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Goal: Write a c++ program in MS Visual Studio 2010 (on win7 x64 machine) that reads in a netCDF file. Compile/build program in Visual Studio 2010 Release or Debug x64. Execute the program.<u></u><u></u></p>
<p class="MsoNormal">The netCDF file I am trying to read in, has one variable in it. That variable is a 3d raster 76x40x93 of float32 type.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Steps I have taken:<u></u><u></u></p>
<p><u></u><span>1.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Download binaries from <a href="http://www.gisinternals.com/sdk/PackageList.aspx?file=release-1600-x64-gdal-1-8-mapserver-6-0.zip" target="_blank">http://www.gisinternals.com/sdk/PackageList.aspx?file=release-1600-x64-gdal-1-8-mapserver-6-0.zip</a><u></u><u></u></p>
<p><u></u><span>2.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Create .lib files from .dll(s)<u></u><u></u></p><p><u></u><span>3.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Follow instruction from download binary site, paths/linkers to library and gdalplugins etc..<u></u><u></u></p>
<p><u></u><span>4.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Use code from API tutorial for c++ <a href="http://www.gdal.org/gdal_tutorial.html" target="_blank">http://www.gdal.org/gdal_tutorial.html</a>, also pasted below<u></u><u></u></p>
<p><u></u><span>5.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Compile the program (everything compiles fine).<u></u><u></u></p><p><u></u><span>6.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>Run the program, does not bomb, but offers bad results.<u></u><u></u></p>
<p><u></u><span>7.<span style="font:7.0pt "Times New Roman""> </span></span><u></u>If you look at the c++ code tutorial in step 4 it has various print statements. Here are the results from those print statements<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Driver: netCDF/Network Common Data Format<u></u><u></u></p><p class="MsoNormal">Size is 76x40x93<u></u><u></u></p><p class="MsoNormal">Projection is ‘ ’<u></u><u></u></p>
<p class="MsoNormal">Block=76x1 Type=Float32, ColorInterp=Undefinded<u></u><u></u></p><p class="MsoNormal">Min=72.905d Max 115.625d<u></u><u></u></p><p class="MsoNormal">Data=100.216d<u></u><u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal" style="text-autospace:none">Problem:<u></u><u></u></p><p class="MsoNormal" style="text-autospace:none"><u></u> <u></u></p><p class="MsoNormal" style="text-autospace:none">When I get a “band” and get the block size, the block size is reported as 76x1 (as in the snips below). I expected the block size to be 76x40<u></u><u></u></p>
<p class="MsoNormal" style="text-autospace:none"><u></u> <u></u></p><p class="MsoNormal" style="text-autospace:none"> <span style="font-size:9.5pt;font-family:Consolas">poBand = poDataset->GetRasterBand( 1 );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">When I read the block (putting the snip below in a nested loop for column and row) I get the proper data in that 76x1 (76 values) block, but I can’t move onto the next row (ie row > 0). Which makes sense because the block is only 76x1. Also, if I get band “2” the same thing, good data, but only one column to work with. What am I missing? How do I retrieve the full band of 76x40? I even tried a JPEG file and got similar results? <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">poBand->RasterIO( GF_Read, column, row, nXSize, 1, <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> pafScanline, nXSize, 1, GDT_Float32, <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> 0, 0 );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal">Thanks in advance for any help or advice,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">James<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">
<u></u> <u></u></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">My program<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">typedef</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">__int64</span> _OFF_T;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal_priv.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"netcdf.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal_frmts.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"netcdfdataset.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_config.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_conv.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_error.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_hash_set.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_port.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_string.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_vsi.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"cpl_minixml.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal_pam.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal_version.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"gdal_vrt.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"ogr_core.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"ogr_spatialref.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515">"ogr_srs_api.h"</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">#include</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:#A31515"><iostream></span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">using</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">namespace</span> std;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green">//const char *pszFilename = "\\IMG_3527.jpg";</span><span style="font-size:9.5pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green">//const char *pszFilename = "\\<a href="http://hada2eugsi.nc" target="_blank">hada2eugsi.nc</a>";</span><span style="font-size:9.5pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">const</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">char</span> *pszFilename = <span style="color:#A31515">"\\<a href="http://james_test.nc" target="_blank">james_test.nc</a>"</span>;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:green">//const char *pszFilename = "\\CRUTEM3.nc";</span><span style="font-size:9.5pt;font-family:Consolas"><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">const</span><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">char</span> *netcdfmeta (<span style="color:#A31515">""</span>);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">char</span><span style="font-size:9.5pt;font-family:Consolas"> ** ppinfo;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:Consolas"> * pncid; <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue">int</span><span style="font-size:9.5pt;font-family:Consolas"> main()<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">{<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALAllRegister();<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( <span style="color:#A31515">"VRT"</span> );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALGetMetadata(poDataset,netcdfmeta);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:green">//poDataset->GetPamInfo();</span><u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poDataset->GetMetadata(netcdfmeta);<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALOpenInfo(pszFilename, GA_ReadOnly ,ppinfo);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:green">//GDALGetGeoTransform( GDALDatasetH, double * );</span><u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( poDataset == NULL )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> {<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"did not open file"</span>);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> }<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">double</span> adfGeoTransform[6];<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Driver: %s/%s\n"</span>,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poDataset->GetDriver()->GetDescription(), <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Size is %dx%dx%d\n"</span>, <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> poDataset->GetRasterXSize(), poDataset->GetRasterYSize(),<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poDataset->GetRasterCount() );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( poDataset->GetProjectionRef() != NULL )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Projection is `%s'\n"</span>, poDataset->GetProjectionRef() );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> {<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Origin = (%.6f,%.6f)\n"</span>,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> adfGeoTransform[0], adfGeoTransform[3] );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Pixel Size = (%.6f,%.6f)\n"</span>,<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> adfGeoTransform[1], adfGeoTransform[5] );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> }<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALRasterBand *poBand;<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">int</span> nBlockXSize, nBlockYSize;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">int</span> bGotMin, bGotMax;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">double</span> adfMinMax[2];<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poBand = poDataset->GetRasterBand( 1 );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Block=%dx%d Type=%s, ColorInterp=%s\n"</span>,<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> nBlockXSize, nBlockYSize,<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALGetDataTypeName(poBand->GetRasterDataType()),<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALGetColorInterpretationName(<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> poBand->GetColorInterpretation()) );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> adfMinMax[0] = poBand->GetMinimum( &bGotMin );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> adfMinMax[1] = poBand->GetMaximum( &bGotMax );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( ! (bGotMin && bGotMax) )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax);<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Min=%.3fd, Max=%.3f\n"</span>, adfMinMax[0], adfMinMax[1] );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( poBand->GetOverviewCount() > 0 )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Band has %d overviews.\n"</span>, poBand->GetOverviewCount() );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">if</span>( poBand->GetColorTable() != NULL )<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"Band has a color table with %d entries.\n"</span>, <u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poBand->GetColorTable()->GetColorEntryCount() );<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">float</span> *pafScanline;<u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <span style="color:blue">int</span> nXSize = poBand->GetXSize();<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"><u></u> <u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> pafScanline = (<span style="color:blue">float</span> *) CPLMalloc(<span style="color:blue">sizeof</span>(<span style="color:blue">float</span>)*nXSize);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> poBand->RasterIO( GF_Read, 0, 0, nXSize, 1, <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas"> pafScanline, nXSize, 1, GDT_Float32, <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> 0, 0 );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> printf( <span style="color:#A31515">"data=%.3fd"</span>, *pafScanline );<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> <u></u><u></u></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas"> GDALClose(poDataset);<u></u><u></u></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas">}<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">
<u></u> <u></u></p></div></div><br>_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br></blockquote></div><br>