I am trying to apply an ascii (241 rows, 463 columns) to netlogo using the following code:
set my-dataset "data/my-folder/my-file.asc"
resize-world 0 gis:width-of (gis:load-dataset my-dataset) - 1 0 gis:height-of (gis:load-dataset my-dataset) - 1
gis:set-world-envelope-ds (gis:envelope-of (gis:load-dataset my-dataset))
gis:apply-raster (gis:load-dataset my-dataset) my-variable
In the resize-world command, I added the -1 since netlogo starts at 0, while gis:width-of starts at 1.The result is a netlogo world with min-pycor 0 max-pycor 240 and min-pxcor 0 max-pxcor 462 (a 241x463 world), which matches the size of my ascii perfectly. The gis-world envelop command makes sure that the extent is similar for the ascii en the Netlogo world. I checked this, and again it matches perfectly.
The problem I am facing is that although the netlogo rows and columns match the ascii rows and columns, the applied ascii is displaced by 1 in the y direction. The top row of the netlogo world is filled with zero's, while the top row of my ascii is filled with high values.
FIGURE: top row is red, showing 0 values, where they should not be 0.
Does anybody know what the problem is? Or how to correctly apply the ascii to the netlogo world so that one ascii value fills the corresponding netlogo patch?
Maybe additional to this: can I stop netlogo from automatically resampling, so that I know for sure that the values in netlogo are the same as those in my ascii.
Thank you for your help
More info:
ascii header
NCOLS 463
NROWS 241
XLLCORNER 2.54710299910375
YLLCORNER 49.4941766658013
CELLSIZE 0.00833333333339921
NODATA_value -9999
netlogo envelope:
show gis:world-envelope
observer: [2.5471029991037497 6.405436332467584 49.49417666580129 51.502509999150504]
my-file envelope:
show gis:envelope-of gis:load-dataset my-dataset
observer: [2.54710299910375 6.405436332467584 49.4941766658013 51.502509999150504]
Note that there is a slight rounding difference, which I just cannot erase no matter how I code the world-envelope. In any case, considering that it is such a tiny difference I don't think this is the problem.
- edit: I checked what actually happened by exporting the netlogo values to a raster, and comparing them in ArcGIS. It is not a simple problem of resampling. Actually, the top row just has missing values, without shifting values. Furthermore, the middle column and row duplicate, causing everything to shift outwards from the middle towards the bottom and right. I added a simple illustration, hoping that this would clarify the problem.