当前位置: 首页>>代码示例>>C#>>正文


C# Dataset.Dispose方法代码示例

本文整理汇总了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;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:32,代码来源:GdalRasterProvider.cs

示例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);
        }
开发者ID:alamsal,项目名称:GDAL_UTILS_Csharp,代码行数:63,代码来源:ComputeStatistics.cs


注:本文中的OSGeo.GDAL.Dataset.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。