ArcGis里,大量要素选择的问题

javaokay 2007-06-15 01:46:10
大家好,最近学习中遇到个问题,就是在 AcrGis里面,关于大量要素选择后作统计的问题:问题如下
在MapControl里有大量的要素 ,点,线,面的都有,要做的就是用选择工具选择一片区域后,能统计所选择 的要素的属性,问题出在,如果我选择的 要素数目比较少的话,没什么问题,但是如果选择的要素太多,就抛出ComException
代码如下
Private Sub 统计ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 统计ToolStripMenuItem.Click
Try
Dim features As IEnumFeature = Me.AxMapControl1.ActiveView.Selection
If features Is Nothing Then
MessageBox.Show("你没有选择要统计的区域,请选择要统计的区域!")
Exit Sub
End If
features.Reset()
Dim feature As IFeature = features.Next()
While Not feature Is Nothing
If feature Is Nothing Then
Exit While
End If
System.Console.WriteLine(feature.Class.AliasName & ":" & feature.OID)
feature = features.Next()
End While
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try

End Sub
请高人指点
...全文
1213 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yujunyong 2007-07-11
  • 打赏
  • 举报
回复
精华收藏
jxufeng 2007-07-09
  • 打赏
  • 举报
回复
这个问题不会是处在这里把
System.Console.WriteLine(feature.Class.AliasName & ":" & feature.OID)

是不是writeline太多了?
yemao20 2007-07-06
  • 打赏
  • 举报
回复
呵呵.比较简单的.不过VB的代码看着都感觉不想看呀.
javaokay 2007-06-30
  • 打赏
  • 举报
回复
十分感谢两位的支持,谢谢了!!!!!!
anonymousvampire 2007-06-28
  • 打赏
  • 举报
回复
在ArcGis中,IEnumFeature主要是用来画图层选择集的,为了进行优化,默认是只返回100条记录,而且只返回数据的shape信息,如果你需要返回更多的数据需要进行强化设置,添加如下代码:
Dim pEnumFeatureSetup As IEnumFeatureSetup
Set pEnumFeatureSetup = pEnumFeature
pEnumFeatureSetup.AllFields = True
但是并不推荐在map选择集中返回全部数据,而是应该返回每个图层的选择集,以下是ESRI的帮助文档,你可以看看:
From ArcObjects Help:
Note, only the shape field is guaranteed with the selection. This is the default and exists for performance reasons. The IMap::FeatureSelection property is typically used to draw the map selection, not access feature attributes. This is particularly noticeable with shapefiles and coverage but also in geodatabases if the selection is large enough. Use IEnumFeatureSetup::AllFields to set a flag indicating all fields be returned with the selection. If you want to loop through the map selection to perform an operation, it is typically best to access each layer's selection rather than the entire map's selection. See the example for a sample of each.
IMap FeatureSelection Example
Below are three different methods for looping through a map's selection. The first script uses IMap::FeatureSelection. The problem with this approach is that there is no guarantee all of the fields for a particular feature class are returned in the query. By default only the Shapefield is asked for as this property is primarily used to draw the map's selected features only, not access their attributes. However, this approach may be used when editing; in this case, all the fields are requested.
The second sample is the same as the first except it additionally uses IEnumFeatureSetup to explicitly tell the map to retrieve all fields.
The last sample is the best approach. It is rarely the case that one would want to loop through the entire selection in such a manner as the first two samples. The exception is of course when drawing the selected features or determining the total selection count. Instead, it is much more practical to loop through the selections belonging only to the layers of interest. For example, in a case where only selected polygons are of interest, it is much more efficient to only check the geometry type of each feature class rather than each feature returned by IMap::FeatureSelection.

kukuma210 2007-06-27
  • 打赏
  • 举报
回复
我也不知道,帮你顶一下吧

2,142

社区成员

发帖
与我相关
我的任务
社区描述
它是一种特定的十分重要的空间信息系统。它是在计算机硬、软件系统支持下,对整个或部分地球表层(包括大气层)空间中的有关地理分布数据进行采集、储存、管理、运算、分析、显示和描述的技术系统。
社区管理员
  • 地理信息系统
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧