/******************************************** 宿鑫 2018.9 www.ixxin.cn 符合GPL开源协议 *********************************************/ // ReadSentine2.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> #include <gdal_priv.h> using namespace std; enum SentinelSubDT { Resu10m, Resu20m, Resu60m, TrueColor }; int _tmain(int argc, _TCHAR* argv[]) { SentinelSubDT S2DT = Resu60m; const char* pSenFile = "E:\\Sentine2\\S2B_MSIL1C_20180810T024539_N0206_R132_T50SQF_20180810T053506.SAFE\\MTD_MSIL1C.xml"; const char* pDstFile = "E:\\Sentine2\\S2B_MSIL1C_20180810T024539_N0206_R132_T50SQF_20180810T053506.SAFE\\TrueColorFile.tif"; char pSubFile[1000]; char* pSubName; switch (S2DT) { case Resu10m: pSubName = "10m:EPSG_32650"; break; case Resu20m: pSubName = "20m:EPSG_32650"; break; case Resu60m: pSubName = "60m:EPSG_32650"; break; case TrueColor: pSubName = "TCI:EPSG_32650"; break; default: pSubName = "10m:EPSG_32650"; break; } //printf("%s", pSubName); sprintf(pSubFile, "SENTINEL2_L1C:%s:%s", pSenFile, pSubName); <a href="https://www.ixxin.cn/tag/gdal/" title="查看更多关于GDAL的文章" target="_blank">GDAL</a>AllRegister(); <a href="https://www.ixxin.cn/tag/gdal/" title="查看更多关于GDAL的文章" target="_blank">GDAL</a>Dataset* pSenDs = (<a href="https://www.ixxin.cn/tag/gdal/" title="查看更多关于GDAL的文章" target="_blank">GDAL</a>Dataset*)<a href="https://www.ixxin.cn/tag/gdal/" title="查看更多关于GDAL的文章" target="_blank">GDAL</a>Open(pSubFile, GA_ReadOnly); if (pSenDs == NULL) { cout << "打开失败" << endl; return false; } GDALDriver* pDStDrive = (GDALDriver*)GDALGetDriverByName("GTiff"); GDALDataset* pDstDs = pDStDrive->CreateCopy(pDstFile, pSenDs, FALSE, NULL, GDALTermProgress, NULL); GDALClose(GDALDatasetH(pSenDs)); GDALClose(GDALDatasetH(pDstDs)); return 0; }
支持博主的点击一下网站头部与底部的广告哦,扫一下支付宝红包。
如有问题,请发邮件到:s_xxin@qq.com