Netlogo doesen't recognize the GIS coordinates in the defined envelope of the world, it treats them as netologo world coordinates

Viewed 213

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.

My setup procedure:

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
1 Answers

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.

Related