我想将一个HDF从UTM(WGS84)重新投影到正弦(WGS84),所以我尝试用GDALAutoCreateWarpedVRT
它来完成它。代码如下:
hSrcDS = (GDALDataset*)GDALOpen("HJ1ACCD1.hdf", GA_ReadOnly);
const char *pszSrcWKT = NULL;
char* pszDstWKT = NULL;
//pszSrcWKT = ProjectionStr;
pszSrcWKT=GDALGetProjectionRef(hSrcDS);
CPLAssert( pszSrcWKT != NULL &&strlen(pszSrcWKT) > 0 );
OGRSpatialReference oSRS;
oSRS.SetSinusoidal(0,0,0);
oSRS.SetWellKnownGeogCS("WGS84");
oSRS.exportToWkt(&pszDstWKT );
GDALWarpOptions*psWarpOptions = GDALCreateWarpOptions();
psWarpOptions->dfWarpMemoryLimit=500*1024*1024;
hDstDS=(GDALDataset*)(GDALDataset*)GDALAutoCreateWarpedVRT(hSrcDS,pszSrcWKT,pszDstWKT,GRA_Bilinear ,20,psWarpOptions);
GDALDriver *poDriverTiff;
poDriverTiff=GetGDALDriverManager()->GetDriverByName("GTIFF");
poDriverTiff->CreateCopy("d:\\toto.tif",(GDALDataset*)hDstDS,false,NULL,NULL,NULL);
当我设置oSRS.SetSinusoidal(0,0,0)
时,结果看起来不错,但分辨率翻了一番(从 30 到 60)。太奇怪了。