我想从shapefile导入一些多边形,并创建具有特定坐标的海龟(一组将放置在特定多边形中的点)。我成功地导入了多边形,设置了世界的封套.然而,当我试图添加海龟并将它们放在一个特定的位置(setxy)时,它将它们添加到相同的位置(就像这两个点具有相同的坐标,而它们没有)。我选择了点的坐标,我知道它们在空间上属于不同的进口多边形。我更改了像素大小(尽管这可能是问题所在),但什么也没有。我意识到,NetLogo将这些坐标解释为“本地坐标”,而不是“地理信息系统”。但是网络徽标不应该在定义的世界范围内识别地理信息系统坐标吗?
有人能帮我解决这个问题吗?告诉我我做错了什么。
我的设置过程:
to setup
set paldrino gis:load-dataset "paldrino.shp"
let world ( gis:envelope-of paldrino )
gis:set-world-envelope (world)
;; Make them visible
foreach gis:feature-list-of paldrino [ ;for each polygon
polygon ->
ask patches gis:intersecting polygon [
set pcolor pink
]]
create-turtles 1[
set color blue
set size 15
setxy 34.6255826 48.2408635 ;; here's the problem, netlogo treats this as the network coordinates of the world, not as GIS coordinates
]
create-turtles 1[
set color green
set size 15
setxy 34.8056851 48.1885275 ;; here's the problem, netlogo treats this as the network coordinates of the world, not as GIS coordinates
end发布于 2020-07-29 14:51:35
我找到了另一种解决办法。当然不是最好的,但现在是我唯一拥有的。我创建了一个额外的过程,重新确定地理信息系统坐标到NetLogo坐标。
to-report nl-x [#x]
let world gis:envelope-of paldrino
let minx item 0 world
let maxx item 1 world
report ((#x - minx) / (maxx - minx)) * (max-pxcor - min-pxcor) + min-pxcor
end
to-report nl-y [#y]
let world gis:envelope-of paldrino
let miny item 2 world
let maxy item 3 world
report ((#y - miny) / (maxy - miny)) * (max-pycor - min-pycor) + min-pycor
end当我想要设置海龟的坐标时,我以如下方式调用这个过程:
setxy nl-x(34.6255826) nl-y(48.2408635)如果有人有更好的计算解决方案,我可以解释为什么我的代码在问题中没有工作,请这样做。我会接受这个答案而不是这个。
https://stackoverflow.com/questions/63057644
复制相似问题