<html><div style='background-color:'><P><BR><BR></P>
<DIV>
<DIV class=RTE>
<P>Hello Frank,</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sorry for the delay, I am not only new to GDAL but to c++ in general, I mostly worked on VB and Java, so it slows any coding triple fold. I actually&nbsp;backed up&nbsp;your gdalwarp.cpp and replaced it with&nbsp;my simple version because I don't know yet how to modify the nmake configuration to compile mine separately, and it WORKED, for some reason, the only complaining it did was this:</P>
<P>C:\GDAL\Release\bin&gt;gdalwarp<BR>ERROR 6: SetColorTable() not supported for multi-sample TIFF files.<BR>ERROR 6: SetColorTable() not supported for multi-sample TIFF files.<BR>ERROR 6: SetColorTable() not supported for multi-sample TIFF files.<BR>:0...10...20...30...40...50...60...70...80...90...100 - done.</P>
<P>Here is the code of the gdalwarp.cpp, probably some of the includes are redundant, but I just added them from the original gdalwarp.cpp just to be on the safe side:</P>
<P>#include "gdal_priv.h"<BR>#include "gdalwarper.h"<BR>#include "ogr_spatialref.h"<BR>#include "ogr_srs_api.h"<BR>#include "cpl_string.h"<BR>#include &lt;string.h&gt;</P>
<P>char fileNameIn[] = "C:\\GDAL\\TESTING\\Test01\\Images\\imagein.tif";<BR>char fileNameOut[] = "C:\\GDAL\\TESTING\\Test01\\Images\\imageout.tif";<BR>char fileNameRef[] = "C:\\GDAL\\TESTING\\Test01\\Images\\imagein_old.tif";</P>
<P>void main()<BR>{&nbsp;<BR>&nbsp;&nbsp;&nbsp; GDALDataset&nbsp; *poDataset;<BR>&nbsp;&nbsp;&nbsp; GDALDatasetH&nbsp; hSrcDS, hDstDS;</P>
<P>&nbsp;&nbsp;&nbsp; GDALAllRegister();</P>
<P>&nbsp;&nbsp;&nbsp; hSrcDS = GDALOpen( fileNameIn, GA_ReadOnly );</P>
<P>&nbsp;&nbsp;&nbsp; poDataset = (GDALDataset *) hSrcDS;<BR>&nbsp;&nbsp;&nbsp; if( poDataset == NULL )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;exit(1);<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; GDALDriverH hDriver;<BR>&nbsp;&nbsp;&nbsp; GDALDataType eDT;</P>
<P>&nbsp;&nbsp;&nbsp; CPLAssert( hSrcDS != NULL );<BR>&nbsp;&nbsp;&nbsp; eDT = GDALGetRasterDataType(GDALGetRasterBand(hSrcDS,1));</P>
<P>&nbsp;&nbsp;&nbsp; hDriver = GDALGetDriverByName("GTiff");<BR>&nbsp;&nbsp;&nbsp; CPLAssert( hDriver != NULL );</P>
<P>&nbsp;&nbsp;&nbsp; const char *pszSrcWKT = NULL;<BR>&nbsp;&nbsp;&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; OGRSpatialReference oSRS;</P>
<P>&nbsp;&nbsp;&nbsp; //oSRS.SetUTM(17, TRUE);</P>
<P>&nbsp;&nbsp;&nbsp; //oSRS.SetWellKnownGeogCS("WGS84");<BR>&nbsp;&nbsp;&nbsp; oSRS.importFromProj4("+proj=latlong +datum=WGS84");</P>
<P>&nbsp;&nbsp;&nbsp; oSRS.exportToWkt( &amp;pszDstWKT );</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; 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; char *apszOptions[] = {"INTERLEAVE=PIXEL", NULL};<BR>&nbsp;&nbsp;&nbsp; hDstDS = GDALCreate(hDriver, fileNameOut, nPixels, nLines, GDALGetRasterCount(hSrcDS), eDT, apszOptions);<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; CPLAssert( hDstDS != NULL );</P>
<P>&nbsp;&nbsp;&nbsp; GDALSetProjection(hDstDS, pszDstWKT);<BR>&nbsp;&nbsp;&nbsp; GDALSetGeoTransform(hDstDS, adfDstGeoTransform);</P>
<P>&nbsp;&nbsp;&nbsp; GDALColorTableH hCT;</P>
<P>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,1));<BR>&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,1), hCT);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,2));<BR>&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,2), hCT);<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,3));<BR>&nbsp;&nbsp;&nbsp; GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,3), hCT);</P>
<P>&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;&nbsp;&nbsp; psWarpOptions-&gt;panDstBands[1] = 2;<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;panDstBands[2] = 3;</P>
<P>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pfnProgress = GDALTermProgress;</P>
<P>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pTransformerArg = GDALCreateGenImgProjTransformer(hSrcDS,&nbsp;&nbsp;&nbsp;&nbsp; GDALGetProjectionRef(hSrcDS), hDstDS, GDALGetProjectionRef(hDstDS), FALSE, 0.0, 1);<BR>&nbsp;&nbsp;&nbsp; psWarpOptions-&gt;pfnTransformer = GDALGenImgProjTransform;</P>
<P>&nbsp;&nbsp;&nbsp; GDALWarpOperation oOperation;</P>
<P>&nbsp;&nbsp;&nbsp; oOperation.Initialize(psWarpOptions);</P>
<P>&nbsp;&nbsp;&nbsp; oOperation.ChunkAndWarpImage(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));</P>
<P>&nbsp;&nbsp;&nbsp; GDALDestroyGenImgProjTransformer(psWarpOptions-&gt;pTransformerArg);<BR>&nbsp;&nbsp;&nbsp; GDALDestroyWarpOptions(psWarpOptions);</P>
<P>&nbsp;&nbsp;&nbsp; GDALClose(hDstDS);<BR>&nbsp;&nbsp;&nbsp; GDALClose(hSrcDS);<BR>}</P>
<P>I am not sure what was the problem though, the only thing I did was clean up the code, remove all comments, that's all.</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks a lot.</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; Ilya.</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] UTM to Lat/Long projection
<DIV></DIV>&gt;Date: Wed, 4 May 2005 15:36:04 -0400
<DIV></DIV>&gt;
<DIV></DIV>&gt;On 5/4/05, Ilya Serebrianik &lt;predator2448@hotmail.com&gt; wrote:
<DIV></DIV>&gt; &gt;
<DIV></DIV>&gt; &gt;
<DIV></DIV>&gt; &gt;
<DIV></DIV>&gt; &gt; Hello Frank,
<DIV></DIV>&gt; &gt;
<DIV></DIV>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It does not fail in a sense that it crashes, it just doesn't do
<DIV></DIV>&gt; &gt; anything to the image as was the case before I added projection to be
<DIV></DIV>&gt; &gt; latlong. The pszSrcWKT, and pszDstWKT seem to correct, and the functions
<DIV></DIV>&gt; &gt; that compose the latter do not complain either. Here is the code I use, I
<DIV></DIV>&gt; &gt; apologize for the mess, don't want to erase experimental lines:
<DIV></DIV>&gt;
<DIV></DIV>&gt;Ilya,
<DIV></DIV>&gt;
<DIV></DIV>&gt;If you boil this down to a simple commandline program with the
<DIV></DIV>&gt;filenames hardcoded, and also provide the input data file I will
<DIV></DIV>&gt;try and figure out what is happening here.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Best regards,
<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></div></html>