Why does Netlogo export asc result with different cell size from input files?

49 Views Asked by At

I have a model built by using GIS data (an ascii of the digital terrain model -DTM- and another of roads) with a patch resolution of 30 * 30 meters for both inputs (see image1 and image 2). After running the model and importing resulting information into ArcGis Pro, I find that the pixel size of the raster is of 50*50 meters (image 3. I thought that the output patch/pixel size wound be the same as the input info... at least approximately, and not have a difference of 20m between them... Here's the code of GIS extension:

to setup-terrain ;; Pull in the asc terrain files and apply it to create patch data from gis data.
  set elevation gis:load-dataset "dtm_30m.asc" ;; change the GIS terrain data by changing this file.
  gis:set-world-envelope gis:envelope-of elevation
  let horizontal-gradient gis:convolve elevation 3 3 [ 1 1 1 0 0 0 -1 -1 -1 ] 1 1
  let vertical-gradient gis:convolve elevation 3 3 [ 1 0 -1 1 0 -1 1 0 -1 ] 1 1
  set slope gis:create-raster gis:width-of elevation gis:height-of elevation gis:envelope-of elevation
  set aspect gis:create-raster gis:width-of elevation gis:height-of elevation gis:envelope-of elevation
  let x 0
  repeat (gis:width-of slope)
  [ let y 0
    repeat (gis:height-of slope)
    [ let gx gis:raster-value horizontal-gradient x y
      let gy gis:raster-value vertical-gradient x y
      if ((gx <= 0) or (gx >= 0)) and ((gy <= 0) or (gy >= 0))
      [ let s sqrt ((gx * gx) + (gy * gy))
        gis:set-raster-value slope x y s
        ifelse (gx != 0) or (gy != 0)
        [ gis:set-raster-value aspect x y atan gy gx ]
        [ gis:set-raster-value aspect x y 0 ] ]
      set y y + 1 ]
    set x x + 1 ]
  gis:set-sampling-method aspect "bilinear"
  gis:apply-raster elevation p-elevation ;; take all the data from the raster and apply it onto a given patch variable
  gis:apply-raster aspect p-aspect
  gis:apply-raster slope p-slope

  ask patches with [p-elevation > 0] [
    set pcolor scale-color 35 p-elevation .6 250
  ]
  ask patches with [p-elevation < 0] [set p-elevation 0]
  ask patches with [p-elevation = "NaN"] [set p-elevation 0]
end

to setup-roads ;; Pull in the asc road files and apply it to create patch data from gis data.
  set road-data gis:load-dataset "new_roads_30m.asc" ;; change the GIS road data by changing this file.
  gis:set-world-envelope gis:envelope-of elevation
  ask patches with [pcolor = 0] [ set p-elevation 0]

  gis:apply-raster road-data p-road-data ;; take all the data from the raster and apply it onto a given patch variable

  ask patches with [p-road-data > 0]
  [
    set pcolor scale-color yellow p-road-data 0 40
  ]
  ask patches with [p-road-data < 0] [set p-road-data 0]
end

Why is this happening and how can I make output files have the desired resolution of 30m?

0

There are 0 best solutions below