<html><div style='background-color:'><P><BR><BR></P>
<DIV>
<DIV class=RTE>
<P>Hello Frank,</P>
<P> 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 backed up your gdalwarp.cpp and replaced it with 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>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 <string.h></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>{ <BR> GDALDataset *poDataset;<BR> GDALDatasetH hSrcDS, hDstDS;</P>
<P> GDALAllRegister();</P>
<P> hSrcDS = GDALOpen( fileNameIn, GA_ReadOnly );</P>
<P> poDataset = (GDALDataset *) hSrcDS;<BR> if( poDataset == NULL )<BR> {<BR> exit(1);<BR> }</P>
<P> GDALDriverH hDriver;<BR> GDALDataType eDT;</P>
<P> CPLAssert( hSrcDS != NULL );<BR> eDT = GDALGetRasterDataType(GDALGetRasterBand(hSrcDS,1));</P>
<P> hDriver = GDALGetDriverByName("GTiff");<BR> CPLAssert( hDriver != NULL );</P>
<P> const char *pszSrcWKT = NULL;<BR> char *pszDstWKT;</P>
<P> pszSrcWKT = GDALGetProjectionRef( hSrcDS );<BR> CPLAssert( pszSrcWKT != NULL && strlen(pszSrcWKT) > 0 );</P>
<P> OGRSpatialReference oSRS;</P>
<P> //oSRS.SetUTM(17, TRUE);</P>
<P> //oSRS.SetWellKnownGeogCS("WGS84");<BR> oSRS.importFromProj4("+proj=latlong +datum=WGS84");</P>
<P> oSRS.exportToWkt( &pszDstWKT );</P>
<P> void *hTransformArg;</P>
<P> hTransformArg = GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT, FALSE, 0, 1 );<BR> CPLAssert( hTransformArg != NULL );</P>
<P> double adfDstGeoTransform[6];<BR> int nPixels = 0, nLines = 0;<BR> CPLErr eErr;</P>
<P> eErr = GDALSuggestedWarpOutput( hSrcDS, GDALGenImgProjTransform, hTransformArg, adfDstGeoTransform, &nPixels, &nLines );<BR> CPLAssert( eErr == CE_None );</P>
<P> GDALDestroyGenImgProjTransformer( hTransformArg );</P>
<P> char *apszOptions[] = {"INTERLEAVE=PIXEL", NULL};<BR> hDstDS = GDALCreate(hDriver, fileNameOut, nPixels, nLines, GDALGetRasterCount(hSrcDS), eDT, apszOptions);<BR> <BR> CPLAssert( hDstDS != NULL );</P>
<P> GDALSetProjection(hDstDS, pszDstWKT);<BR> GDALSetGeoTransform(hDstDS, adfDstGeoTransform);</P>
<P> GDALColorTableH hCT;</P>
<P> hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,1));<BR> GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,1), hCT);<BR> <BR> hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,2));<BR> GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,2), hCT);<BR> <BR> hCT = GDALGetRasterColorTable(GDALGetRasterBand(hSrcDS,3));<BR> GDALSetRasterColorTable(GDALGetRasterBand(hDstDS,3), hCT);</P>
<P> GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();</P>
<P> psWarpOptions->hSrcDS = hSrcDS;<BR> psWarpOptions->hDstDS = hDstDS;<BR> psWarpOptions->nBandCount = 3;<BR> psWarpOptions->panSrcBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount);<BR> psWarpOptions->panSrcBands[0] = 1;<BR> psWarpOptions->panSrcBands[1] = 2;<BR> psWarpOptions->panSrcBands[2] = 3;<BR> psWarpOptions->panDstBands = (int *) CPLMalloc(sizeof(int) * psWarpOptions->nBandCount);<BR> psWarpOptions->panDstBands[0] = 1;<BR> psWarpOptions->panDstBands[1] = 2;<BR> psWarpOptions->panDstBands[2] = 3;</P>
<P> psWarpOptions->pfnProgress = GDALTermProgress;</P>
<P> psWarpOptions->pTransformerArg = GDALCreateGenImgProjTransformer(hSrcDS, GDALGetProjectionRef(hSrcDS), hDstDS, GDALGetProjectionRef(hDstDS), FALSE, 0.0, 1);<BR> psWarpOptions->pfnTransformer = GDALGenImgProjTransform;</P>
<P> GDALWarpOperation oOperation;</P>
<P> oOperation.Initialize(psWarpOptions);</P>
<P> oOperation.ChunkAndWarpImage(0, 0, GDALGetRasterXSize(hDstDS), GDALGetRasterYSize(hDstDS));</P>
<P> GDALDestroyGenImgProjTransformer(psWarpOptions->pTransformerArg);<BR> GDALDestroyWarpOptions(psWarpOptions);</P>
<P> GDALClose(hDstDS);<BR> 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> Thanks a lot.</P>
<P> Ilya.</P></DIV>
<DIV></DIV>>From: Frank Warmerdam <fwarmerdam@gmail.com>
<DIV></DIV>>Reply-To: warmerdam@pobox.com
<DIV></DIV>>To: Ilya Serebrianik <predator2448@hotmail.com>
<DIV></DIV>>CC: gdal-dev@xserve.flids.com
<DIV></DIV>>Subject: Re: [Gdal-dev] UTM to Lat/Long projection
<DIV></DIV>>Date: Wed, 4 May 2005 15:36:04 -0400
<DIV></DIV>>
<DIV></DIV>>On 5/4/05, Ilya Serebrianik <predator2448@hotmail.com> wrote:
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > Hello Frank,
<DIV></DIV>> >
<DIV></DIV>> > It does not fail in a sense that it crashes, it just doesn't do
<DIV></DIV>> > anything to the image as was the case before I added projection to be
<DIV></DIV>> > latlong. The pszSrcWKT, and pszDstWKT seem to correct, and the functions
<DIV></DIV>> > that compose the latter do not complain either. Here is the code I use, I
<DIV></DIV>> > apologize for the mess, don't want to erase experimental lines:
<DIV></DIV>>
<DIV></DIV>>Ilya,
<DIV></DIV>>
<DIV></DIV>>If you boil this down to a simple commandline program with the
<DIV></DIV>>filenames hardcoded, and also provide the input data file I will
<DIV></DIV>>try and figure out what is happening here.
<DIV></DIV>>
<DIV></DIV>>Best regards,
<DIV></DIV>>--
<DIV></DIV>>---------------------------------------+--------------------------------------
<DIV></DIV>>I set the clouds in motion - turn up | Frank Warmerdam, warmerdam@pobox.com
<DIV></DIV>>light and sound - activate the windows | http://pobox.com/~warmerdam
<DIV></DIV>>and watch the world go round - Rush | Geospatial Programmer for Rent
<DIV></DIV></DIV></div></html>