1.算法功能简介
等值线图能直观地展示数据的变化趋势,是众多领域展示成果的重要图建之一,被广泛应用于石油勘探、矿物开采、气象预报等众多领域。等值线的绘制是指从大量采样数据中提取出具有相同值的点的信息,并生成形态完整、位置精确的等值线的过程,包括等值线网格化、等值线追踪、等值线光滑、等值线填充与标注几个处理步骤。
PIE支持算法功能的执行,下面对等值线生成算法功能进行介绍。
2.算法功能实现说明
2.1. 实现步骤
2.2. 算法参数
C#算法DLL | PIE.CommonAlgo.dll |
C#算法名称 | PIE.CommonAlgo.RasterToContourContructAlgo |
参数结构体 | RasterToContourContruct_Exchange_Info |
参数说明 |
BandIndex | Int | 波段 |
BAutoSetStartEndValue | bool | 是否自动计算起始终止值 |
BClosed | bool | 是否闭合 |
BGenerateContourFace | bool | 是否生成等值面 |
BGenerateContourLine | bool | 是否生成等值线 |
EndValue | double | 终止值 |
InputRasterDataset | IRasterDataset | 输入栅格数据集 |
OutputContourFaceFDataset | IFeatureDataset | 输出等值面(内存) |
OutputContourLineFDataset | IFeatureDataset | 输出等值线 (内存) |
SampleRatio | int | 采样比 |
StartValue | double | 起始值 |
ValueInterval | double | 间隔 |
2.3. 示例代码
数据路径 | 百度云盘地址下/ PIE示例数据/栅格数/04.World/World.tif |
视频路径 | 百度云盘地址下/PIE视频教程/10.算法调用/实用工具/等值线生成.avi |
示例代码 |
/// <summary>
/// 等值线生成算法测试
/// </summary>
private void Test_RasterToContourContructAlgo()
{
#region 1参数设置
#region 获取待加载文件路径
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
openFileDialog.Title = "请选择要打开的数据";
openFileDialog.Multiselect = true;
openFileDialog.Filter = "Tiff|*.tif;*.tiff|所有文件|*.*";
if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
string strFileName = openFileDialog.FileName;
#endregion
IRasterDataset rDataset = PIE.DataSource.DatasetFactory.OpenRasterDataset(strFileName, OpenMode.ReadOnly);
RasterToContourContruct_Exchange_Info info = new RasterToContourContruct_Exchange_Info();
info.InputRasterDataset = rDataset;
info.BandIndex = ;
info.BAutoSetStartEndValue = true;
info.BGenerateContourFace = true;
info.BGenerateContourLine = true;
info.BClosed = true;
info.ValueInterval = ;
info.SampleRatio = ;
#endregion
//2、算法执行
PIE.CommonAlgo.RasterToContourContructAlgo alog = new RasterToContourContructAlgo();
alog.Params = info;
alog.Execute();
//3、结果显示
info = alog.Params as RasterToContourContruct_Exchange_Info;
if (info.OutputContourFaceFDataset != null)//等值面
{
IFeatureLayer featureLayerFace = new FeatureLayer();
featureLayerFace.FeatureClass = new FeatureClass(info.OutputContourFaceFDataset);
m_HookHelper.FocusMap.AddLayer(featureLayerFace as ILayer);
}
if (info.OutputContourLineFDataset != null)//等值线
{
IFeatureLayer featureLayerLine = new FeatureLayer();
featureLayerLine.FeatureClass = new FeatureClass(info.OutputContourLineFDataset);
m_HookHelper.FocusMap.AddLayer(featureLayerLine as ILayer);
}
m_HookHelper.ActiveView.Refresh();
(rDataset as IDisposable).Dispose();
rDataset = null;
} |
2.4. 示例截图