GDAL实现遥感影像数据压缩

bat365入口 📅 2025-08-28 19:34:32 👤 admin 👁️ 6323 ❤️ 283
GDAL实现遥感影像数据压缩

/**

* BaseProcesses是我自己封装的一个函数,大家使用正常GDAL API即可,功能都是一样的

**/

Gdal.AllRegister();

BaseProcesses.GdalRegister();

Dataset ds ;

Dataset dd;

int strict = 0;

int xsize;

int ysize;

int iBandNumRef;

string sBandDataType;

double[] dGeoTransform;

string sGeoProjectionRef;

string [] options=new string[]{"TILED=YES", "COMPRESS=LZW"};

string path = "D:\\hxl\\yasuotest\\cptest3.tif";

BaseProcesses.OpenImage(out ds,"D:\\hxl\\yasuotest\\610325201610190000006256250160001.tif");

BaseProcesses.GetBaseInforOfImage(ds, out xsize, out ysize, out iBandNumRef, out sBandDataType, out dGeoTransform, out sGeoProjectionRef);

Driver di = ds.GetDriver();

di.CreateCopy(path, ds, strict, options, null, null);

BaseProcesses.OpenImage(out dd, path);

for (int i = 1; i <= ds.RasterCount;i++)

{

int[] dataarry = new int[xsize*ysize];

ds.GetRasterBand(i).ReadRaster(0, 0, xsize, ysize, dataarry, xsize, ysize,0,0);

dd.GetRasterBand(i).WriteRaster(0, 0, xsize, ysize, dataarry, xsize, ysize, 0, 0);

}

dd.FlushCache();

dd.Dispose();

相关推荐

faceu激萌中设置狐狸贴纸的具体步骤介绍
bat365入口

faceu激萌中设置狐狸贴纸的具体步骤介绍

📅 07-06 👁️ 6782