XDL TIP
[XDL2.0] 256 x 256 타일 형식의 TIFF 파일로 저장하기
작성자관리자 작성일2021-01-07 조회수3,764
<em>// 1. XRasterIO객체를 생성하고 초기화를 수행.</em>
XRasterIO RasterIO = new XRasterIO();
String strError = "";
if (RasterIO.Initialize(out strError) == false)
{
return;
}
<em>// 2. XRasterIO객체에 파일 경로를 입력하여 XRSLoadFile를 생성</em>
XRSLoadFile xrsFileInput = RasterIO.LoadFile("d:test.xdm", out strError, false, eIOCreateXLDMode.None);
if (xrsFileInput == null) return;
<em> // 3. XRSLoadFile객체에 들어 있는 XDMBand를 꺼내어 XRSSaveFile객체에 추가</em>
XRSSaveFile fileSave = new XRSSaveFile();
for (int i = 0; i < xrsFileInput.NumBand; i++)<br> {
XDMBand band = (XDMBand)xrsFileInput.GetBandAt(i);
if (band == null) continue;
fileSave.AddBand(ref band);
}
<em> // 4. XRSFileSave의 MetaData에 생성 옵션 설정
// 아래의 생성 옵션은 GDAL의 Raster Driver에서 각 출력 형식의 "Create Options" 참고</em>
XRSMetaData metaData = new XRSMetaData();
metaData.SetValue("TILED", "YES");
metaData.SetValue("BLOCKXSIZE", "256");
metaData.SetValue("BLOCKYSIZE", "256");
fileSave.MetaData = metaData;
String strFilePathSave = @"d:output.tif";
if (!RasterIO.Export(ref fileSave, strFilePathSave, "GTiff", out strError, null))
{
MessageBox.Show("Fail!!!!");
}
else
{
MessageBox.Show("End");
}
XRasterIO RasterIO = new XRasterIO();
String strError = "";
if (RasterIO.Initialize(out strError) == false)
{
return;
}
<em>// 2. XRasterIO객체에 파일 경로를 입력하여 XRSLoadFile를 생성</em>
XRSLoadFile xrsFileInput = RasterIO.LoadFile("d:test.xdm", out strError, false, eIOCreateXLDMode.None);
if (xrsFileInput == null) return;
<em> // 3. XRSLoadFile객체에 들어 있는 XDMBand를 꺼내어 XRSSaveFile객체에 추가</em>
XRSSaveFile fileSave = new XRSSaveFile();
for (int i = 0; i < xrsFileInput.NumBand; i++)<br> {
XDMBand band = (XDMBand)xrsFileInput.GetBandAt(i);
if (band == null) continue;
fileSave.AddBand(ref band);
}
<em> // 4. XRSFileSave의 MetaData에 생성 옵션 설정
// 아래의 생성 옵션은 GDAL의 Raster Driver에서 각 출력 형식의 "Create Options" 참고</em>
XRSMetaData metaData = new XRSMetaData();
metaData.SetValue("TILED", "YES");
metaData.SetValue("BLOCKXSIZE", "256");
metaData.SetValue("BLOCKYSIZE", "256");
fileSave.MetaData = metaData;
String strFilePathSave = @"d:output.tif";
if (!RasterIO.Export(ref fileSave, strFilePathSave, "GTiff", out strError, null))
{
MessageBox.Show("Fail!!!!");
}
else
{
MessageBox.Show("End");
}