ArcGIS中的循环道路网络提取

时间:2014-01-15 06:08:22

标签: arcgis

我有一个带有一些悬挂节点和一些环状道路的道路网络。我已经拆除了悬空的道路,现在我也想拆除环状道路。任何人都可以告诉我锄头我能做到吗提前致谢(:

1 个答案:

答案 0 :(得分:0)

1)寻找道路网络中的循环: 对于形成3/4环的道路,使用弯曲度公式(线端/长度之间的距离)。 Python公式是:

!Shp_lngth! / math.pow(math.pow( !X_Start! - !X_End! , 2 ) + math.pow( !Y_Start! - !Y_End!, 2 ), 0.5) > 2

对于刚刚在道路尽头的循环(如cul de sac灯泡),使用“创建路线”工具,找到MMonotonicity值为4或以上的道路。

2)寻找道路网络中的悬空节点: 使用此代码

using System;
using System.Collections.Generic;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Carto;
using System.Windows.Forms;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.EditorExt;


namespace KalkulatorAddin
{
    public class TestButton : ESRI.ArcGIS.Desktop.AddIns.Button
    {
        public TestButton()
        {
        }

        protected override void OnClick()
        {
            try
            {
                Test();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        protected override void OnUpdate()
        {
        }
        public void Test()
        {
            var fSel = ArcMap.Document.FocusMap.get_Layer(0) as IFeatureSelection;
            fSel.Clear();
            var dangleOids = GetDangleOids();
            if (dangleOids.Count > 0)
            {
                var oidarray = dangleOids.ToArray();
                fSel.SelectionSet.AddList(dangleOids.Count, ref oidarray[0]);
            }
            ((IActiveView)ArcMap.Document.FocusMap).Refresh();
        }

        private List<int> GetDangleOids()
        {
            UID topoUiD = new UID();
            topoUiD.Value = "esriEditorExt.TopologyExtension";
            var topoExt = ArcMap.Application.FindExtensionByCLSID(topoUiD) as ITopologyExtension;
            var mapTopology = topoExt.CurrentTopology as IMapTopology;
            if (mapTopology == null)
                throw new Exception("map topology not found");

            //assume just one class in the map topology
            var extent = ((IGeoDataset)mapTopology.get_Class(0)).Extent;
            mapTopology.Cache.Build(extent, false);

            var dangleOids = new List<int>();
            var nodes = mapTopology.Cache.Nodes;
            nodes.Reset();
            ITopologyNode node;
            while ((node = nodes.Next()) != null)
            {
                // sometimes degree is referred to as valence
                if (node.Degree == 1)
                {
                    var parents = node.Parents;
                    parents.Reset();
                    int oid = parents.Next().m_FID;
                    if (!dangleOids.Contains(oid))
                        dangleOids.Add(oid);
                }
            }
            return dangleOids;
        }
    }
}