Netlogo - Misalignment with Imported Gis Shapefiles

NetLogo - misalignment with imported GIS shapefiles

Nice screen shot, thanks for providing that, it makes the problem easy to grasp. It looks like the farther from the origin, the worse the discrepancy is, like the error is radiating out from the origin.

I know the GIS extension documentation recommends gis:set-world-envelope (list min-pxcor max-pxcor min-pycor max-pycor), but I have to wonder if it's actually correct. min/max-pxcor/pycor are the minimum and maximum patch coordinates, not the minimum and maximum turtle coordinates. So for example if max-pxcor is 10, then a turtle's x coordinate can be as high as 10.499999[...], and if min-pxcor is -10, a turtle's x coordinate can be as low -10.5. Thus world-width is 21, not 20.

Maybe try changing it to gis:set-world-envelope (list min-pxcor - 0.5 max-pxcor + 0.5 min-pycor - 0.5 max-pycor + 0.5) and see if that fixes it. Or if it doesn't fix it exactly, try flipping the signs or try 1 instead of 0.5. It sure looks from the screen shot like the problem is an off-by-one or off-by-0.5 error.

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

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.

GIS Vector use in Netlogo and patches compatibility

Yes, but no, but maybe. It depends what you actually need to do. Raster datasets in GIS are a good example of this 'problem'- they are discrete representations of real-world data, but typically broken up into cells / a grid. For example, elevation is sometimes represented in 20-30 meter cells- that doesn't mean the whole cell is the same elevation, but there are restrictions in how we can represent real world 'analog' data in a digital world. The NetLogo 'world' is similar- you can modify the resolution of your world by changing the patch sizes to best allow you to explore the question at hand. If you use a very small patch size (relative to your spatial dataset) and use something like gis:apply-coverage, you could likely get a decent approximation of a continuous world. You could check out the Model Library example called "GIS Gradient Example" for an example of 'continuous' real-world data being represented in a grid system.

Sample Image

Alternatively, you may find that the gis:have-relationship? or the gis:relationship-of functions will allow you to explore the way that your different parcels are related, and potentially process things in this way. However, it really will depend on your need / goals if either of these options would work.



Related Topics



Leave a reply



Submit