Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing raster data into NetLogo results in a column with all patch variables = 0

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.

like image 608
Anisha Jayadevan Avatar asked Jul 05 '18 08:07

Anisha Jayadevan


1 Answers

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] 
 ] )
like image 159
Anisha Jayadevan Avatar answered Nov 20 '22 12:11

Anisha Jayadevan