<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=content-type>
<STYLE type=text/css>
BLOCKQUOTE{margin-Top: 0px; margin-Bottom: 0px; margin-Left: 2em}
</STYLE>

<META name=GENERATOR content="MSHTML 11.00.9600.17801"><!-- flashmail style begin -->
<STYLE type=text/css>
body {border-width:0;margin:0}
img {border:0;margin:0;padding:0}
</STYLE>
<BASE target=_blank><!-- flashmail style end --></HEAD>
<BODY 
style="BORDER-LEFT-WIDTH: 0px; FONT-SIZE: 10.5pt; FONT-FAMILY: 微软雅黑; BORDER-RIGHT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; COLOR: #000000; MARGIN: 12px; LINE-HEIGHT: 1.5; BORDER-TOP-WIDTH: 0px" 
marginwidth="0" marginheight="0"><STATIONERY>
<DIV>Hi, </DIV>
<DIV> </DIV>
<DIV>I used GDAL to reproject the TM images, and the original projection of the 
TM images was longitude/latitude WGS84, the final projection was UTM 51. The 
codes I used is as following:</DIV>
<DIV> </DIV>
<DIV>void doCore()<BR>{</DIV>
<DIV> </DIV>
<DIV> GDALDataType eDT;<BR> GDALDataset *hDstDS;<BR> GDALDataset 
*hSrcDS;</DIV>
<DIV> </DIV>
<DIV> GDALAllRegister();</DIV>
<DIV> </DIV>
<DIV> //  cache Max<BR> GDALSetCacheMax(1024*1024*1024);</DIV>
<DIV> </DIV>
<DIV> // open file<BR> hSrcDS = (GDALDataset *)GDALOpen( 
"G:\\Data\\TM\\0_Water_Vapor_Near_Infrared.tif", GA_ReadOnly 
);<BR> CPLAssert( hSrcDS != NULL );</DIV>
<DIV> </DIV>
<DIV> GDALRasterBand *iBand1 = hSrcDS->GetRasterBand(1); </DIV>
<DIV> </DIV>
<DIV> const char *pszSrcWKT;<BR> char *pszDstWKT = 
NULL;<BR> pszSrcWKT = GDALGetProjectionRef( hSrcDS );<BR> CPLAssert( 
pszSrcWKT != NULL && strlen(pszSrcWKT) > 0 );</DIV>
<DIV> </DIV>
<DIV><BR>    // set UTM<BR> OGRSpatialReference 
oSRS;<BR> oSRS.SetUTM(51, 
TRUE);<BR> oSRS.SetWellKnownGeogCS("WGS84");<BR> oSRS.exportToWkt( 
&pszDstWKT );</DIV>
<DIV> </DIV>
<DIV> void *hTransformArg;<BR> hTransformArg = 
GDALCreateGenImgProjTransformer( hSrcDS, pszSrcWKT, NULL, pszDstWKT, FALSE, 0, 1 
);<BR> CPLAssert( hTransformArg != NULL );</DIV>
<DIV> </DIV>
<DIV> // calculate 6 parameters <BR> double 
adfDstGeoTransform[6];<BR> int nPixels=0, nLines=0;<BR> CPLErr 
eErr;<BR> eErr = GDALSuggestedWarpOutput( hSrcDS, GDALGenImgProjTransform, 
hTransformArg, adfDstGeoTransform, &nPixels, &nLines 
);<BR> CPLAssert( eErr == CE_None 
);<BR> GDALDestroyGenImgProjTransformer(hTransformArg);</DIV>
<DIV> </DIV>
<DIV><BR> // create out file<BR> eDT = 
GDALDataType(iBand1->GetRasterDataType());<BR> GDALDriver *hDriver = 
(GDALDriver *)GDALGetDriverByName( "GTiff" );<BR> CPLAssert( hDriver != 
NULL );<BR> hDstDS = (GDALDataset *)GDALCreate( hDriver, 
"G:\\data\\TM\\out.tif", nPixels, nLines, GDALGetRasterCount(hSrcDS), eDT, NULL 
);<BR> CPLAssert( hDstDS != NULL );</DIV>
<DIV> </DIV>
<DIV> // write projection 
info<BR> hDstDS->SetProjection(pszDstWKT);<BR> hDstDS->SetGeoTransform(adfDstGeoTransform);</DIV>
<DIV> </DIV>
<DIV> // create warp info <BR> GDALWarpOptions *psWarpOptions = 
GDALCreateWarpOptions();</DIV>
<DIV> </DIV>
<DIV> psWarpOptions->dfWarpMemoryLimit = 
1024*1024*1024;<BR> psWarpOptions->hSrcDS = 
hSrcDS;<BR> psWarpOptions->hDstDS = hDstDS;</DIV>
<DIV> </DIV>
<DIV> psWarpOptions->nBandCount = 
1;<BR> psWarpOptions->panSrcBands = (int *) CPLMalloc(sizeof(int) 
);<BR> psWarpOptions->panSrcBands[0] = 
1;<BR> psWarpOptions->panDstBands = (int *) CPLMalloc(sizeof(int) 
);<BR> psWarpOptions->panDstBands[0] = 1;</DIV>
<DIV> </DIV>
<DIV> psWarpOptions->pfnProgress = GDALTermProgress;</DIV>
<DIV> </DIV>
<DIV> psWarpOptions->pTransformerArg = GDALCreateGenImgProjTransformer( 
hSrcDS, pszSrcWKT, hDstDS, pszDstWKT, FALSE, 0, 1 
);<BR> psWarpOptions->pfnTransformer = GDALGenImgProjTransform;</DIV>
<DIV> </DIV>
<DIV> // do it <BR> GDALWarpOperation 
oOPeration;<BR> oOPeration.Initialize(psWarpOptions);<BR> oOPeration.ChunkAndWarpMulti(0, 
0, nPixels, nLines);</DIV>
<DIV> </DIV>
<DIV> GDALDestroyGenImgProjTransformer(psWarpOptions->pTransformerArg);<BR> GDALDestroyWarpOptions( 
psWarpOptions );<BR> CPLFree(pszDstWKT);</DIV>
<DIV> </DIV>
<DIV> GDALClose(hDstDS);<BR> GDALClose(hSrcDS);<BR>}</DIV>
<DIV> </DIV>
<DIV>However, the time which the codes spent to process one image is about 70 
seconds in VS 2010 x64 release, and in ENVI/IDL, it was only spend 45 
seconds. So, I am wonder whether something wrong in my codes? Thanks!</DIV>
<DIV> </DIV>
<DIV>Yours,</DIV>
<DIV>Xia Lang</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: Verdana; COLOR: #c0c0c0">
<DIV align=left>2015-05-18</DIV>
<HR id=SignNameHR 
style="BORDER-TOP: #c0c0c0 1px solid; HEIGHT: 1px; BORDER-RIGHT: 0px; WIDTH: 122px; BORDER-BOTTOM: 0px; BORDER-LEFT: 0px" 
align=left>
<SPAN id=_FlashSignName>xialang2012</SPAN> </DIV></STATIONERY></BODY></HTML>