首页 文章

shapefile不重叠补丁

提问于
浏览
1

我正在构建一个模型,要求我将shapefile加载到netlogo . 我已经这样做了,视图上显示的 Map 对应于它应该是什么 . 问题是shapefile没有与补丁重叠 . 我的shapefile由x | y |属性组成,我在文件中有80万行 . 理想的情况是让每一行对应一个补丁但是当我执行计数补丁时它只有1089.更糟糕的是,当我要求属性值时,每个补丁检索NaN . 我将粘贴部分与此问题相关的代码:

globals [ mintempcm-dataset
  maxtemphm-dataset
  precipitation-dataset
  meantemp-dataset
  color-list
]

patches-own [
  mintempcm
  maxtemphm
  meantemp
  precipitation
]
to setup
  ca

  gis:load-coordinate-system (word "WGS_84_Geographic.prj")
  set maxtemphm-dataset gis:load-dataset "mxtwm.shp"


  gis:set-world-envelope (gis:envelope-union-of 
    (gis:envelope-of maxtemphm-dataset)

  )
  gis:apply-coverage maxtemphm-dataset "MAXTEMPHM" maxtemphm

  ask patches[

    set maxtemphm maxtemphm

  ]

  gis:set-drawing-color blue
  gis:draw maxtemphm-dataset 1


  reset-ticks
end

我错过了什么或做错了什么?为了澄清,我需要使文件的每个坐标对应一个补丁并将该属性传递给补丁 .

谢谢 .

1 回答

  • 1

    您可以使用 gis:intersecting 来执行此操作,但它对您想要执行的操作效率不高 . 例如,我从this site下载了具有一些免费gis数据的机场数据集 . 机场数据集(ne_10m_airports.shp)包含每个机场的点数据和每个机场的一些信息 . 要为补丁分配一些数据,请参阅下面的注释中的一些信息:

    extensions [ gis ]
    
    globals [ airports ]
    
    patches-own [ airport-name ]
    
    to setup
      ca
      resize-world 0 125 0 50
      set-patch-size 5
    
      ; Load the dataset
      set airports gis:load-dataset "ne_10m_airports.shp"
      gis:set-world-envelope gis:envelope-of airports
    
      ; For each point listed in 'airports', ask any patches
      ; that are intersecting that point to take the name
      ; of the airport that intersects them (since these are points,
      ; intersection in this case means the airport coordinates
      ; lie within the patch.
    
      foreach gis:feature-list-of airports [
        x ->
        ask patches gis:intersecting x [
          set airport-name gis:property-value x "NAME"
          set pcolor red
        ]
      ]
    
      reset-ticks
    end
    

    您可以使用温度数据集中的"MAXTEMPHM"值执行此操作 . 但是,您必须使用NetLogo世界大小来确保补丁数量与您拥有的点数相对应__3232149_仅将gis数据集与NetLogo世界对齐,它不需要't affect the patches present. If you have 800000 temperature points you want to load in, you'd需要让你的NetLogo世界大约895个补丁广场,这是一个非常大的世界 . 如上所述,加载温度数据将花费一些时间 . 使用栅格数据集和 gis:apply-raster 会使事情变得更简单,更高效(并且明显更快) .

相关问题