When I use this code to import a raster layer into NetLogo and resize the world, all patch variables of the last column is zero when it should contain data. This happens only for a few rasters from the same landscape.
set rasterLayer gis:load-dataset "x.asc"
resize-world 0 (gis:width-of rasterLayer) -1 0 (gis:height-of rasterLayer) -1
gis:set-world-envelope gis:envelope-of rasterLayer
gis: apply-raster rasterLayer
Without the '-1' when resizing the world, I get a column of NaN values (Importing raster data into NetLogo results in a row/column of NaN values).
The dimensions of this raster are correct; the column of 0 values is not an extra one, meaning that some data is lost.
Thanks to @Tyr : a workaround to this possible bug was posted here. This is the code I used, for NetLogo 6, to make sure that the raster was applied properly to the NetLogo world :
file-open "data/my-folder/my-file.asc"
let temp []
repeat 6 [let header file-read-line] ; skip first 6 lines of header
while [file-not-at-end?][
set temp lput file-read temp
]
file-close
(foreach sort patches temp [
[a b] -> ask a [ set my-variable b]
] )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With