<html><div style='background-color:'><DIV class=RTE>
<P>Hello Frank,</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thank you for your very quick response, I changed the values like you said and the output file size is indeed almost the same as the original, just a couple hunderds kilobytes bigger, which makes sense since the transition from NAD83 to WGS84 should not have much effect. The squishing effect, however, is still present and is still greyscale.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For my experimentations I use visual&nbsp;C++ 6 and my processing is triggered by just one button click, as you will notice it is mostly your tutorial example from the main GDAL website, here is the whole code:</P>
<P>void CTest01Dlg::OnButtonProcess() <BR>{<BR>&nbsp;// ------------ Example of initializing an image into the GDALDataset object<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; GDALDataset&nbsp; *poDataset;</P>
<P>&nbsp;&nbsp;&nbsp; // -------------- Reprojection example</P>
<P>&nbsp;GDALDatasetH&nbsp; hSrcDS, hDstDS;</P>
<P>&nbsp;&nbsp;&nbsp; // Open input and output files. </P>
<P>&nbsp;&nbsp;&nbsp; GDALAllRegister();</P>
<P>&nbsp;&nbsp;&nbsp; hSrcDS = GDALOpen( fileNameIn, GA_ReadOnly );</P>
<P>&nbsp;poDataset = (GDALDataset *) hSrcDS;<BR>&nbsp;&nbsp;&nbsp; if( poDataset == NULL )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)strcat("The input file does not exist: ", fileNameIn));<BR>&nbsp;&nbsp;exit(1);<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;GDALDriverH hDriver;<BR>&nbsp;&nbsp;&nbsp; GDALDataType eDT;</P>
<P>&nbsp;&nbsp;&nbsp; // Open the source file. </P>
<P>&nbsp;&nbsp;&nbsp; CPLAssert( hSrcDS != NULL );<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; // Create output with same datatype as first input band. </P>
<P>&nbsp;&nbsp;&nbsp; eDT = GDALGetRasterDataType(GDALGetRasterBand(hSrcDS,1));</P>
<P>&nbsp;//CString str;<BR>&nbsp;//str.Format("%d\n",eDT);<BR>&nbsp;//AfxMessageBox(str);</P>
<P>&nbsp;&nbsp;&nbsp; // Get output driver (GeoTIFF format)</P>
<P>&nbsp;&nbsp;&nbsp; hDriver = GDALGetDriverByName( "GTiff" );<BR>&nbsp;&nbsp;&nbsp; CPLAssert( hDriver != NULL );</P>
<P>&nbsp;&nbsp;&nbsp; // Get Source coordinate system. </P>
<P>&nbsp;&nbsp;&nbsp; const char *pszSrcWKT = NULL;<BR>&nbsp;char *pszDstWKT;</P>
<P>&nbsp;&nbsp;&nbsp; pszSrcWKT = GDALGetProjectionRef( hSrcDS );<BR>&nbsp;&nbsp;&nbsp; CPLAssert( pszSrcWKT != NULL &amp;&amp; strlen(pszSrcWKT) &gt; 0 );</P>
<P>&nbsp;&nbsp;&nbsp; // Setup output coordinate system that is UTM 11 WGS84. </P>
<P>&nbsp;&nbsp;&nbsp; OGRSpatialReference oSRS;</P>
<P>&nbsp;&nbsp;&nbsp; oSRS.SetUTM( 17, TRUE );<BR>&nbsp;&nbsp;&nbsp; oSRS.SetWellKnownGeogCS( "WGS84" );</P>
<P>&nbsp;&nbsp;&nbsp; oSRS.exportToWkt( &amp;pszDstWKT );</P>
<P>&nbsp;&nbsp;&nbsp; // Create a transformer that maps from source pixel/line coordinates<BR>&nbsp;&nbsp;&nbsp; // to destination georeferenced coordinates (not destination <BR>&nbsp;&nbsp;&nbsp; // pixel line).&nbsp; We do that by omitting the destination dataset<BR>&nbsp;&nbsp;&nbsp; // handle (setting it to NULL). </P>
<P>&nbsp;&nbsp;&nbsp; void *hTransformArg;</P>
<P>&nbsp;&nbsp;&nbsp; hTransformArg = GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT, FALSE, 0, 1 );<BR>&nbsp;&nbsp;&nbsp; CPLAssert( hTransformArg != NULL );</P>
<P>&nbsp;&nbsp;&nbsp; // Get approximate output georeferenced bounds and resolution for file. </P>
<P>&nbsp;&nbsp;&nbsp; double adfDstGeoTransform[6];<BR>&nbsp;&nbsp;&nbsp; int nPixels = 0, nLines = 0;<BR>&nbsp;&nbsp;&nbsp; CPLErr eErr;</P>
<P>&nbsp;&nbsp;&nbsp; eErr = GDALSuggestedWarpOutput( hSrcDS, GDALGenImgProjTransform, hTransformArg, adfDstGeoTransform, &amp;nPixels, &amp;nLines );<BR>&nbsp;&nbsp;&nbsp; CPLAssert( eErr == CE_None );</P>
<P>&nbsp;&nbsp;&nbsp; GDALDestroyGenImgProjTransformer( hTransformArg );</P>
<P>&nbsp;&nbsp;&nbsp; // Create the output file.&nbsp; <BR>&nbsp;hDstDS = GDALCreate( hDriver, fileNameOut, nPixels, nLines, GDALGetRasterCount(hSrcDS), eDT, NULL );<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; CPLAssert( hDstDS != NULL );</P>
<P>&nbsp;&nbsp;&nbsp; // Write out the projection definition. </P>
<P>&nbsp;&nbsp;&nbsp; GDALSetProjection( hDstDS, pszDstWKT );<BR>&nbsp;&nbsp;&nbsp; GDALSetGeoTransform( hDstDS, adfDstGeoTransform );</P>
<P>&nbsp;&nbsp;&nbsp; // Copy the color table, if required.</P>
<P>&nbsp;&nbsp;&nbsp; GDALColorTableH hCT;</P>
<P>&nbsp;// Get the color table of the first (1) band of the source dataset<BR>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,1));<BR>&nbsp;<BR>&nbsp;// --------------- For debugging-----------------------<BR>&nbsp;//str.Format("DEBUG INFO: %d\n",GDALGetRasterCount(hDstDS));<BR>&nbsp;//AfxMessageBox(str);<BR>&nbsp;// ----------------------------------------------------<BR>&nbsp;<BR>&nbsp;// If the color table of the first (1) band of the source dataset is not<BR>&nbsp;// NULL then assign it to the first (1) band of the destination dataset<BR>&nbsp;&nbsp;&nbsp; //if(hCT != NULL)<BR>&nbsp;//{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,1), hCT);<BR>&nbsp;//}</P>
<P>&nbsp;// Get the color table of the second (2) band of the source dataset<BR>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,2));</P>
<P>&nbsp;// If the color table of the second (2) band of the source dataset is not<BR>&nbsp;// NULL then assign it to the second (2) band of the destination dataset<BR>&nbsp;&nbsp;&nbsp; //if(hCT != NULL)<BR>&nbsp;//{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,2), hCT);<BR>&nbsp;//}</P>
<P>&nbsp;// Get the color table of the third (3) band of the source dataset<BR>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,3));</P>
<P>&nbsp;// If the color table of the third (3) band of the source dataset is not<BR>&nbsp;// NULL then assign it to the third (3) band of the destination dataset<BR>&nbsp;&nbsp;&nbsp; //if(hCT != NULL)<BR>&nbsp;//{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,3), hCT);<BR>&nbsp;//}</P>
<P>&nbsp;CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)"Setup warp options ...");</P>
<P>&nbsp;&nbsp;&nbsp; // Setup warp options. <BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();</P>
<P>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;hSrcDS = hSrcDS;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;hDstDS = hDstDS;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;nBandCount = 3;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panSrcBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions-&gt;nBandCount);<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panSrcBands[0] = 1;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panSrcBands[1] = 2;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panSrcBands[2] = 3;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panDstBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions-&gt;nBandCount);<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panDstBands[0] = 1;<BR>&nbsp;psWarpOptions-&gt;panDstBands[1] = 2;<BR>&nbsp;psWarpOptions-&gt;panDstBands[2] = 3;</P>
<P>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pfnProgress = GDALTermProgress;<BR>&nbsp;<BR>&nbsp;CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)"Establishing transformer ...");</P>
<P>&nbsp;&nbsp;&nbsp; // Establish reprojection transformer. </P>
<P>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pTransformerArg = GDALCreateGenImgProjTransformer(hSrcDS, GDALGetProjectionRef(hSrcDS), hDstDS, GDALGetProjectionRef(hDstDS), FALSE, 0.0, 1);<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pfnTransformer = GDALGenImgProjTransform;</P>
<P>&nbsp;&nbsp;&nbsp; // Initialize and execute the warp operation.<BR>&nbsp;<BR>&nbsp;CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)"Executing ...");</P>
<P>&nbsp;&nbsp;&nbsp; GDALWarpOperation oOperation;</P>
<P>&nbsp;&nbsp;&nbsp; // Initialize transformation operation<BR>&nbsp;oOperation.Initialize(psWarpOptions);</P>
<P>&nbsp;// Perform the transformation<BR>&nbsp;&nbsp;&nbsp; oOperation.ChunkAndWarpImage(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));</P>
<P>&nbsp;// Clean up the intermediate objects<BR>&nbsp;&nbsp;&nbsp; GDALDestroyGenImgProjTransformer(psWarpOptions-&gt;pTransformerArg);<BR>&nbsp;&nbsp;&nbsp; GDALDestroyWarpOptions(psWarpOptions);</P>
<P>&nbsp;CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)"Done ...");</P>
<P>&nbsp;// Close the input and output files<BR>&nbsp;&nbsp;&nbsp; GDALClose(hDstDS);<BR>&nbsp;&nbsp;&nbsp; GDALClose(hSrcDS);&nbsp;<BR>}</P>
<P>void CTest01Dlg::OnButtonCleanup() <BR>{<BR>&nbsp;remove(fileNameOut);<BR>&nbsp;CTest01Dlg::SendDlgItemMessage(IDC_LIST_STATUS, LB_ADDSTRING, 0, (LPARAM)"Cleanup complete ...");<BR>}</P>
<P>I also tried using the precompiled tools from the GDAL website, specifically the warp tool and it also produces the squished effect. Perhaps the GeoTIFF I am using as a source is special in some sense and needs to be processed in a special way, I am not sure. Here is the information extracted using gdalinfo.exe about the image, it is around 75 MB: </P>
<P>Driver: GTiff/GeoTIFF<BR>Size is 5010, 5009<BR>Coordinate System is:<BR>PROJCS["unnamed",<BR>&nbsp;&nbsp;&nbsp; GEOGCS["NAD83",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DATUM["North_American_Datum_1983",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SPHEROID["GRS 1980",6378137,298.2572221010002,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHORITY["EPSG","7019"]],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHORITY["EPSG","6269"]],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PRIMEM["Greenwich",0],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UNIT["degree",0.0174532925199433],<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHORITY["EPSG","4269"]],<BR>&nbsp;&nbsp;&nbsp; PROJECTION["Transverse_Mercator"],<BR>&nbsp;&nbsp;&nbsp; 
PARAMETER["latitude_of_origin",0],<BR>&nbsp;&nbsp;&nbsp; PARAMETER["central_meridian",-81],<BR>&nbsp;&nbsp;&nbsp; PARAMETER["scale_factor",0.9996],<BR>&nbsp;&nbsp;&nbsp; PARAMETER["false_easting",500000],<BR>&nbsp;&nbsp;&nbsp; PARAMETER["false_northing",0],<BR>&nbsp;&nbsp;&nbsp; UNIT["metre",1,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHORITY["EPSG","9001"]],<BR>&nbsp;&nbsp;&nbsp; AUTHORITY["EPSG","26917"]]<BR>Origin = (608999.000000,4845001.000000)<BR>Pixel Size = (0.20000000,-0.20000000)<BR>Corner Coordinates:<BR>Upper Left&nbsp; (&nbsp; 608999.000, 4845001.000) ( 79d38'46.13"W, 43d45'0.13"N)<BR>Lower Left&nbsp; (&nbsp; 608999.000, 4843999.200) ( 79d38'46.86"W, 43d44'27.66"N)<BR>Upper Right (&nbsp; 610001.000, 4845001.000) ( 79d38'1.34"W, 43d44'59.59"N)<BR>Lower Right (&nbsp; 610001.000, 4843999.200) ( 79d38'2.08"W, 43d44'27.13"N)<BR>Center&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (&nbsp; 
609500.000, 4844500.100) ( 79d38'24.10"W, 43d44'43.63"N)<BR>Band 1 Block=5010x1 Type=Byte, ColorInterp=Red<BR>Band 2 Block=5010x1 Type=Byte, ColorInterp=Green<BR>Band 3 Block=5010x1 Type=Byte, ColorInterp=Blue<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thank you for your time and I really appreciate your help. Peter says hi, I am working as an undergrad&nbsp;student in GeoICT.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ilya S.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </P>
<P>&nbsp;</P>
<P>&nbsp;</P></DIV>
<DIV></DIV>&gt;From: Frank Warmerdam &lt;fwarmerdam@gmail.com&gt;
<DIV></DIV>&gt;Reply-To: warmerdam@pobox.com
<DIV></DIV>&gt;To: Ilya Serebrianik &lt;predator2448@hotmail.com&gt;
<DIV></DIV>&gt;CC: gdal-dev@xserve.flids.com
<DIV></DIV>&gt;Subject: Re: [Gdal-dev] Warping GeoTIFF colour image - beginner question(s)
<DIV></DIV>&gt;Date: Mon, 2 May 2005 14:25:53 -0400
<DIV></DIV>&gt;
<DIV></DIV>&gt;On 5/2/05, Ilya Serebrianik &lt;predator2448@hotmail.com&gt; wrote:
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands = (int *) CPLMalloc(sizeof(int) *
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;nBandCount);
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[0] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[1] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[2] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands = (int *) CPLMalloc(sizeof(int) *
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;nBandCount);
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[0] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[1] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[2] = 1;
<DIV></DIV>&gt;
<DIV></DIV>&gt;Ilya,
<DIV></DIV>&gt;
<DIV></DIV>&gt;I think you want the src and dst bands to be:
<DIV></DIV>&gt;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[0] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[1] = 2;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panSrcBands[2] = 3;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[0] = 1;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[1] = 2;
<DIV></DIV>&gt; &gt; psWarpOptions-&gt;panDstBands[2] = 3;
<DIV></DIV>&gt;
<DIV></DIV>&gt;This would explain why you are getting greyscale output.
<DIV></DIV>&gt;I'm less clear on this squishing effect you are seeing.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Best regards,
<DIV></DIV>&gt;
<DIV></DIV>&gt;--
<DIV></DIV>&gt;---------------------------------------+--------------------------------------
<DIV></DIV>&gt;I set the clouds in motion - turn up&nbsp;&nbsp; | Frank Warmerdam, warmerdam@pobox.com
<DIV></DIV>&gt;light and sound - activate the windows | http://pobox.com/~warmerdam
<DIV></DIV>&gt;and watch the world go round - Rush&nbsp;&nbsp;&nbsp;&nbsp;| Geospatial Programmer for Rent
<DIV></DIV></div></html>