Small shift when transforming from GIS to NetLogo coordinates

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Small shift when transforming from GIS to NetLogo coordinates

When storing turtle coordinates as GIS coordinates, and then loading them
into NetLogo by converting them back to NetLogo coordinates, there is a
slight shift in position.

This is the code I use to store NetLogo to GIS coordinates:

let env gis:envelope-of agentToStore
file-open "agentLocations.csv"
file-print (word first env "," last env)

And this is the code I use to convert GIS coordinates back to NetLogo
coordinates (here x and y are coordinates read from the file):

 let envelope gis:world-envelope
 let xscale (max-pxcor - min-pxcor) / (item 1 envelope - item 0 envelope)
 let yscale (max-pycor - min-pycor) / (item 3 envelope - item 2 envelope)
 if x >= item 0 envelope and x <= item 1 envelope
   and y >= item 2 envelope and y <= item 3 envelope[
     let netlogo-x (x - item 0 envelope) * xscale  + min-pxcor
     let netlogo-y (y - item 2 envelope) * yscale + min-pycor
     ask patch (ceiling netlogo-x) (floor netlogo-y) [sprout 1]

Without 'ceiling' and 'floor', the loaded agent is always shifted by a cell
in NetLogo. However even with ceiling and floor, there is still a small
shift by in GIS space for some agents, which affects my output. Is there a
better way of doing this?