I, once again have a question. My previous solution to my problem didn't work as I expected. To remind you, I imported some polygons and had a problem setting some turtles (cities) in the NetLogo world appropriately (to read GIS coordinates from non-gis file and set their position in the world, more on Netlogo doesen't recognize the GIS coordinates in the defined envelope of the world, it treats them as netologo world coordinates). So, in the end, I came up with a solution to transform the GIS coordinates in NetLogo coordinates (nl-x and nl-y procedures). The cities are actually in graphml format with x and y attributes. So, my code is this:
extensions [nw gis]
directed-link-breed [highways highway]
breed [cities city]
highways-own [ name ]
cities-own [ x y ]
globals [ paldrino ]
to setup
ca
;; set the world envelope
gis:load-coordinate-system "wgs84.prj"
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 ->
let temp-color one-of base-colors
ask patches gis:intersecting polygon [
set pcolor temp-color
]]
;; load network
nw:set-context cities highways
nw:load-graphml "highway-network.graphml"
ask cities[
set xcor nl-x(read-from-string x) ;; if I put set xcor read-from-string x, then it will put all the nodes in one point in Netlogo world, same for setxy fix-x(read-from-string x) fix-y (read-from-string y)
set ycor nl-y (read-from-string y)
]
end
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
In the end, the problem is that NetLogo doesn't perfectly align those two files: polygons (paldrino) and network (cities). Approximately it put them ok, but I need them to be perfectly set in the world. For example, some cities should have been in one polygon, but they are in the adjacent polygon. So, for example, this is how NetLogo puts them:
And this is how they should be (read in QGIS):
If anyone please can help me or point me in another direction. I start losing my mind.
Thank you!