问题描述
我想从shapefile导入一些多边形并创建具有特定坐标的乌龟(一组将放置在特定多边形中的点).我成功导入了多边形,设置了世界的信封...但是,当我尝试添加海龟并将它们放置在特定位置(setxy)时,它会将它们添加到同一点(就像那两个点具有相同的坐标),而他们没有).我选择了点的坐标,这些点在空间上属于不同的导入多边形.我更改了像素大小(尽管可能是问题所在),但是什么也没有.我意识到NetLogo会将这些坐标解释为本地坐标,而不是GIS.但是Netlogo不能识别在定义的世界范围内的GIS坐标吗?
有人可以帮我这个忙,并告诉我我在做什么错.
I want to import some polygons from shapefile and create turtles with specific coordinates (a set of points that will be put in specific polygons). I successfully imported the polygons, set the envelope of the world... However, when I tried to add turtles and put them on a specific place (setxy), it added them at the same point (like those two points have the same coordinates, and they have not). And I chose coordinates of the points for which I know they belong spatially to the different imported polygons. I changed the pixel size (though that may be the problem), but nothing. I realized that NetLogo interpreters those coordinates as its' local coordinates, instead of GIS. But shouldn't Netlogo recognize the GIS coordinates in the defined envelope of the world?
Can someone help me with this and tell me what I am doing wrong.
我的设置过程:
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
推荐答案
我找到了替代解决方案.当然不是最好的,但目前只有我一个.我创建了一个附加过程,将GIS坐标重新缩放为NetLogo坐标.
I have found the alternative solution. Certainly is not the best one, but for now is the only I have.I created an additional procedure that rescale GIS coordinates to the NetLogo coordinates.
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
当我想设置海龟的坐标时,我可以通过以下方式调用该过程:
And when I want to set a turtle's coordinates I call the procedure in the following way:
setxy nl-x(34.6255826) nl-y(48.2408635)
如果有人拥有更好的计算解决方案,并且我可以解释为什么我的问题代码无法正常工作,请这样做.我会接受那个答案,而不是这个.
If someone has the better computational solution and can me explain why my code in the question is no working, please do. I will accept that answer instead of this.
这篇关于Netlogo无法识别定义的世界范围内的GIS坐标,而是将其视为netologo世界坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!