本文整理汇总了C#中OSGeo.GDAL.Dataset.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# Dataset.Dispose方法的具体用法?C# Dataset.Dispose怎么用?C# Dataset.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSGeo.GDAL.Dataset
的用法示例。
在下文中一共展示了Dataset.Dispose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WrapDataSetInRaster
private static IRaster WrapDataSetInRaster(string name, Type dataType, Dataset dataset)
{
// todo: what about UInt32?
if (dataType == typeof(int) || dataType == typeof(UInt16))
{
return new GdalRaster<int>(name, dataset);
}
else if (dataType == typeof(short))
{
return new GdalRaster<short>(name, dataset);
}
else if (dataType == typeof(float))
{
return new GdalRaster<float>(name, dataset);
}
else if (dataType == typeof(double))
{
return new GdalRaster<double>(name, dataset);
}
else if (dataType == typeof(byte))
{
return new GdalRaster<byte>(name, dataset);
}
// It was an unsupported type.
if (dataset != null)
{
dataset.Dispose();
if (File.Exists(name)) File.Delete(name);
}
return null;
}
示例2: ReadRasterBlocks
private static void ReadRasterBlocks(ref Dataset valueRaster, ref Dataset zoneRaster)
{
_rasInfoDict = new Dictionary<int, StatisticsInfo>[valueRaster.RasterCount];
int valueRasterBandCount = valueRaster.RasterCount;
int rasterRows = zoneRaster.RasterYSize;
int rasterCols = zoneRaster.RasterXSize;
const int blockSize = AppUtils.GdalUtilConstants.RasterBlockSize;
for (int rasBand = 0; rasBand < valueRasterBandCount; rasBand++)
{
Band bandValueRaster = valueRaster.GetRasterBand(rasBand + 1);
Band bandZoneRaster = zoneRaster.GetRasterBand(1);
_rasInfoDict[rasBand] = new Dictionary<int, StatisticsInfo>();
for (int row = 0; row < rasterRows; row += blockSize)
{
int rowProcess;
if (row + blockSize < rasterRows)
{
rowProcess = blockSize;
}
else
{
rowProcess = rasterRows - row;
}
for (int col = 0; col < rasterCols; col += blockSize)
{
int colProcess;
if (col + blockSize < rasterCols)
{
colProcess = blockSize;
}
else
{
colProcess = rasterCols - col;
}
double[] valueRasterValues = new double[rowProcess * colProcess];
double[] zoneRasterValues = new double[rowProcess * colProcess];
bandValueRaster.ReadRaster(col, row, colProcess, rowProcess, valueRasterValues, colProcess, rowProcess, 0, 0);
bandZoneRaster.ReadRaster(col, row, colProcess, rowProcess, zoneRasterValues, colProcess, rowProcess, 0, 0);
ProcessEachRasterBlock(valueRasterValues, zoneRasterValues, rasBand, ref _rasInfoDict);
}
}
}
//flush rasters cache
valueRaster.FlushCache();
zoneRaster.FlushCache();
valueRaster.Dispose();
zoneRaster.Dispose();
StatisticsExport writer = new StatisticsExport(_zoneFile);
writer.ExportZonalStatistics(ref _rasInfoDict, _cellSize);
}