我正在NetLogo中构建一个基于代理的模型,其中代理步行到一个目标。我正在为NetLogo 6.3使用地理信息系统扩展。在每一个滴答中,他们都会记录他们目前站在一个名为"path“的列表上的补丁。
我想包括一个按钮来导出这个列表到一个shapefile,但我不知道如何做。我认为我需要使用“gis:存储-数据集”函数。我就是这样用的:
to export-path
let file (word "path_output.shp")
if file-exists? file [file-delete file]
file-open file
let exported-path path
gis:store-dataset exported-path file
end在界面页面,我设置了一个按钮,用一个问海龟调用这个过程[]。但是,我收到了错误消息,表示这不是一个数据集。有人能帮我吗?谢谢。
发布于 2022-10-16 21:19:44
为了计算和精确(取决于补丁所代表的面积的大小),我建议海龟不必将补丁存储在它们的列表中,而只是记录它们的坐标(使用类似于envelope-of的东西),这样您就可以使用您的地理信息系统将它们的坐标转换成一个具有更精细控制的shapefile:
extensions [ gis csv ]
turtles-own [ path ]
to setup
ca
reset-ticks
let shp_path "C:/gis_example/british_columbia_administrative.shp"
let prj_path "C:/gis_example/british_columbia_administrative.prj"
gis:load-coordinate-system prj_path
let shp gis:load-dataset shp_path
let base_envelope gis:envelope-of shp
gis:set-world-envelope-ds base_envelope
gis:set-drawing-color white
gis:draw shp 1
ask n-of 3 patches [
sprout 1 [
set path ( list self-ticks-coords )
show path
]
]
end
to-report self-ticks-coords
; Report the current ticks and then middle two 'envelope' values of the turtle
report sentence ticks (reduce sentence sublist gis:envelope-of self 1 3)
end
to go
ask turtles [
rt random 60 - 30
fd 1
set path lput self-ticks-coords path
]
tick
end
to go-10-then-export
repeat 10 [
go
]
let out-list reduce sentence [self-who-tick-coords] of turtles
set out-list fput [ "who" "tick" "x" "y" ] out-list
csv:to-file "C:/gis_example/example_coords.csv" out-list
end
to-report self-who-tick-coords
; Report a formatted list of who, tick, and coordinate vlaues
let who-tick-coord-list map [ i -> ( sentence who i ) ] path
report who-tick-coord-list
end这导出了一个csv,该csv存储海龟标识符、时间步骤和坐标(并且可以灵活地存储您需要的任何信息),这是我认为更有用的。我的两分钱!

从MapCruzin.com下载的数据集
https://stackoverflow.com/questions/74044339
复制相似问题