欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap 谈天说地
   您现在位于: 首页技术专栏ArcGIS应用与开发AO开发 → 正文
去除重复点要素
07-11-21 00:00:00 作者: 出处:
基于arcgis8.x的代码,使用方法:在vba里面使用
 
	
Option Explicit
Sub Test()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    
    SelectPoints pMxDoc.FocusMap.Layer(0)
    
    ' refresh the selection screen cache
    Dim pAV As IActiveView
    Set pAV = pMxDoc.FocusMap
    Dim lCacheID As Long
    lCacheID = pAV.ScreenCacheID(esriViewGeoSelection, Nothing)
    pAV.ScreenDisplay.Invalidate Nothing, True, lCacheID

End Sub

Sub SelectPoints(pFLayer As IFeatureLayer)
    Dim lOIDs() As Long, lCount As Long
    QueryPoints pFLayer.FeatureClass, lOIDs, lCount
    
    Dim pFSel As IFeatureSelection
    Set pFSel = pFLayer
    pFSel.Clear
    If lCount > 0 Then
        pFSel.SelectionSet.AddList lCount, lOIDs(0)
    End If
End Sub

Sub QueryPoints(pFC As IFeatureClass, lOIDs() As Long, _
                ByRef lCount As Long)
    '
    ' sets an array of OID's with features that are intersected
    ' by a feature in the same featureclass with a smaller OID
    '
    Dim pFI2 As IFeatureIndex2
    Set pFI2 = New FeatureIndex
    
    Set pFI2.FeatureClass = pFC
    Dim pGDS As IGeoDataset
    Set pGDS = pFC
    pFI2.Index Nothing, pGDS.Extent
    Debug.Print "index built"
    Dim pIQ2 As IIndexQuery2
    Set pIQ2 = pFI2
    
    Dim pFCur As IFeatureCursor
    Set pFCur = pFC.Search(Nothing, False)
    
    Dim pDict As Scripting.Dictionary
    Set pDict = New Scripting.Dictionary
    
    Dim pFeat As IFeature, l As Long, vOID As Variant, sMsg As String
    Set pFeat = pFCur.NextFeature
    Dim vIntersects As Variant
    Do Until pFeat Is Nothing
        pIQ2.IntersectedFeatures pFeat.Shape, vIntersects
        If UBound(vIntersects) > 0 Then
            For Each vOID In vIntersects
                If vOID > pFeat.OID Then
                    If Not pDict.Exists(CStr(vOID)) Then
                        pDict.Add CStr(vOID), 0
                    End If
                End If
            Next vOID
        End If
        Set pFeat = pFCur.NextFeature
        l = l + 1
        If l Mod 100 = 0 Then
            sMsg = l & " rows processed, pointcount: " & pDict.Count
            Application.StatusBar.Message(0) = sMsg
            Debug.Print sMsg
        End If
    Loop
    
    ' load the array
    l = 0
    If pDict.Count > 0 Then
        ReDim lOIDs(pDict.Count - 1)
        For Each vOID In pDict.Keys
            lOIDs(l) = CLng(vOID)
            l = l + 1
        Next vOID
    End If
    lCount = pDict.Count
End Sub

(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  

    关于我们 友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.

                   滇ICP备05006901号