arcgis engine点匹配代码
时间: 2023-09-19 09:06:12 浏览: 159
以下是 ArcGIS Engine 中进行点匹配的示例代码:
```c#
// 获取当前地图控件中的地图对象
IMap map = axMapControl1.Map;
// 创建点符号以及查询条件
ISymbol symbol = new SimpleMarkerSymbolClass();
symbol.Size = 10;
symbol.Color = new RgbColorClass() { Red = 255 };
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = "POP2000 > 1000000";
// 进行点查询
IFeatureLayer featureLayer = map.get_Layer(0) as IFeatureLayer;
IFeatureCursor featureCursor = featureLayer.Search(queryFilter, true);
IFeature feature = featureCursor.NextFeature();
// 进行点匹配
IIdentify identify = (IIdentify)map;
IArray array = identify.Identify(featureLayer, symbol as ESRI.ArcGIS.Display.IGeometry);
if (array != null)
{
for (int i = 0; i < array.Count; i++)
{
IFeatureIdentifyObj fobj = (IFeatureIdentifyObj)array.get_Element(i);
IFeature identifiedFeature = fobj.Feature;
MessageBox.Show("匹配到的要素 OID 为:" + identifiedFeature.OID.ToString());
}
}
else
{
MessageBox.Show("未匹配到任何要素!");
}
```
这段代码首先从地图控件中获取当前地图对象,然后创建一个点符号和查询条件,通过 `IFeatureLayer.Search` 方法进行点查询,得到一个 `IFeatureCursor` 对象,再从地图对象中获取 `IIdentify` 接口,通过 `IIdentify.Identify` 方法进行点匹配,得到一个 `IArray` 对象,遍历该对象即可获取匹配到的要素。
阅读全文