Performance 道路网形状文件中的矢量特征
我正在使用此代码从一个shapefile在Netlogo中创建我的道路网络。但是,我在foreachgis:?的顶点列表中出错,因为在我的矢量数据集中,?未被识别为矢量特征 我如何解决这个问题Performance 道路网形状文件中的矢量特征,performance,vector,netlogo,shapefile,feature-selection,Performance,Vector,Netlogo,Shapefile,Feature Selection,我正在使用此代码从一个shapefile在Netlogo中创建我的道路网络。但是,我在foreachgis:?的顶点列表中出错,因为在我的矢量数据集中,?未被识别为矢量特征 我如何解决这个问题 to make-road-network clear-links let first-node nobody let previous-node nobody foreach gis:feature-list-of roads [ ; each polyline foreach g
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
您使用的是哪个版本的NetLogo 看起来您在
foreach
s中使用了旧的?
任务语法。在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
您可以在此处阅读到->语法的转换:
您可以在此处了解->和匿名过程的一般情况:看起来您是在NetLogo 5中编写代码的,但现在正在尝试在NetLogo 6中运行它。
foreach
的工作方式发生了重大变化,使用“?”的其他原语也发生了变化。请查看字典中的foreach
以获取新语法的示例。