Gis 关于在netlogo中导入.ppm文件格式,如在cruise模型中所做

Gis 关于在netlogo中导入.ppm文件格式,如在cruise模型中所做,gis,netlogo,Gis,Netlogo,我从Google Earth中选择了一个小地图区域,并将其保存为jpg文件。后来我把它转换成.ppm文件格式。然后我尝试在NetLogo中导入这个.ppm文件。但在以下代码行读取文件时,会出现运行时错误“不允许使用此非标准字符(第5行,字符1)” ask patches [ set pcolor rgb (file-read / 256) (file-read / 256) (file-read / 256) ] 下面是我转换成.ppm(便携式pix地图)文本图形格式的jpg 我正在做的代

我从Google Earth中选择了一个小地图区域,并将其保存为jpg文件。后来我把它转换成.ppm文件格式。然后我尝试在NetLogo中导入这个.ppm文件。但在以下代码行读取文件时,会出现运行时错误“不允许使用此非标准字符(第5行,字符1)”

ask patches [
  set pcolor rgb (file-read / 256) (file-read / 256) (file-read / 256)
]
下面是我转换成.ppm(便携式pix地图)文本图形格式的jpg

我正在做的代码是

 globals [
     mapname
 ]
 to startup ; slow, do just once
     init-map
 end

 to init-map
       set mapname "sangamarea";   set mapname "cruise"
       create-dat mapname
  end

 to create-dat [mapfile]
       print "..creating patches, I'll print 'done' when completed"
       import-ppm mapfile
       export-dat mapfile
       print "..done!"
  end

  to import-ppm [ppmfile]
        let x 0 let y 0 let scale 0 ;locals [x y scale]
         set ppmfile (word ppmfile ".ppm")
         file-close-all
         file-open ppmfile
         set x 1 set y file-read-line
         while [first file-read-line = "#"] [set x x + 1]
            file-close
            file-open ppmfile
            repeat x [set x file-read-line]
              set x file-read
              set y file-read
              set scale 1 + file-read
              if x != random-xcor and y != random-ycor [print "Oops: need to fix screen-size to match ppm file"]
             ask patches [set pcolor rgb (file-read / 256) (file-read / 256) (file-read / 256)]
            file-close 
        cleanup-map
  end

  to cleanup-map
         ask patches with [(floor pcolor) mod 10 = 9] [set pcolor 9.9]
         ask patches with [pcolor != 9.9] [set pcolor round pcolor]
         ask patches with [pcolor > 120] [set pcolor pcolor - 110]
  end

  to export-dat [datfile]
           set datfile word datfile ".dat"
           file-close-all
           if file-exists? datfile [file-delete datfile]
           file-open datfile
           ask patches [file-write floor pcolor if pxcor = max-pxcor [file-print ""]] ;screen-edge-x
          file-close
  end

我不明白为什么会出现错误,不管我的jpeg图像是大尺寸还是.ppm文件包含非数值。我遵循汽车巡航模型的步骤。如需任何帮助,请提前感谢

在Netlogo能够直接导入图像之前,我们在2004年编写了巡航模型。我们使用.ppm图像格式,因为它是可加载的ASCII格式

不久之后,Netlogo添加了一些命令,如
import pcolors
import pcolors rgb
import drawing
和位图扩展

我建议跳过PPM加载过程,直接用
import pcolors rgb
加载.jpg。此外,为了避免影响您的颜色的压缩伪影,请考虑使用.pNG格式。