然后,选择“Building stand-alone applications”或"Using the Winforms ArcGIS engine controls"。
首先查询点坐标的位置要素,然后根据空间查询分析,进行查询县要素上的名称具体代码如下:
IPoint point = new PointClass()
point.X = 94.82//你要查询的点坐标位置
point.Y = 32.61//你要查询的点坐标位置
ISpatialFilter spatialFilter = new SpatialFilterClass()
spatialFilter.Geometry = (point as IPoint) as IGeometry//设置用于筛选几何对象
spatialFilter.GeometryField = "Shape"//设置筛选几何字段
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects//设置空间几何关系
IFeatureLayer featureLayer = this.axMapControl1.Map.get_Layer(0) as IFeatureLayer//县的图层
IFeatureCursor featureCursor = null
featureCursor = featureLayer.FeatureClass.Search(spatialFilter, false)
IFeature feature = null
feature = featureCursor.NextFeature()
while (feature != null)
{
string strName = feature.get_Value(feature.Fields.FindField("NAME")).ToString()//你要查询的县的名称
feature = featureCursor.NextFeature()
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor)
你的IfeatureLayer
是null,然后你定义一个IFeatureLayer对象,将IfeatureLayer
给它,也就是说,
featureLayer
是个空对象,你这儿又直接用空对象,所以报错
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)