在一个shapefile的VectorFeature为路网

时间:2018-04-03 13:18:38

标签: performance vector netlogo shapefile feature-selection

我正在使用此代码从shapefile在Netlogo中创建我的roadnet。但是,我在foreach gis:vertex-lists-of?中出错,因为在我的VectorDataSet 道路中无法识别为VectorFeature。 / p>

我该如何解决这个问题?

to make-road-network
  clear-links
  let first-node nobody
  let previous-node nobody
  foreach gis:feature-list-of roads [ ; each polyline
    foreach gis:vertex-lists-of ? [ ; each polyline segment / coordinate pair
      foreach ? [ ; each coordinate
        let location gis:location-of ?
        if not empty? location [ ; some coordinates are empty []
          create-nodes 1 [
            set color green
            set size 1
            set xcor item 0 location
            set ycor item 1 location
            set hidden? true
            if first-node = nobody [
              set first-node self
            ]
            if previous-node != nobody [
              create-link-with previous-node
            ]
            set previous-node self
          ]
        ]
      ]
      set previous-node nobody
    ]
  ]


end

1 个答案:

答案 0 :(得分:1)

您使用的是哪个版本的NetLogo?

看起来您在?中使用了旧的foreach任务语法。在6.0中,我们使用?语法替换了->语法。所以你的代码会改变如下:

to make-road-network
  clear-links
  let first-node nobody
  let previous-node nobody
  foreach gis:feature-list-of roads [ polyline ->
    foreach gis:vertex-lists-of polyline [ segment ->
      foreach segment [ coordinate ->
        let location gis:location-of coordinate
        if not empty? location [ ; some coordinates are empty []
          create-nodes 1 [
            set color green
            set size 1
            set xcor item 0 location
            set ycor item 1 location
            set hidden? true
            if first-node = nobody [
              set first-node self
            ]
            if previous-node != nobody [
              create-link-with previous-node
            ]
            set previous-node self
          ]
        ]
      ]
      set previous-node nobody
    ]
  ]
end

您可以阅读有关转换到 - >这里的语法:https://ccl.northwestern.edu/netlogo/docs/transition.html#changes-for-netlogo-60

你可以阅读 - >和匿名程序一般在这里:https://ccl.northwestern.edu/netlogo/docs/programming.html#anonymous-procedures