【问题标题】:Create turtles according to real population within vectors根据向量内的真实人口创建海龟
【发布时间】:2018-07-12 12:52:48
【问题描述】:

我想在 NetLogo 中创建一个人口。因此,我想根据该地区的人口在地区内创建海龟。但是,我不完全确定该怎么做。

我得到了区域内的人口作为补丁值:

gis:apply-coverage lor-dataset "GESBEV" population

但是当我用这个创建人口时,我得到的是每个区域内一个区域内的人口数量,而不是每个区域内的人口数量。

是否有可能每个地区只获得一次人口值?我也将感谢任何我可以做进一步阅读的资源。我自己没有找到任何东西。

【问题讨论】:

    标签: vector netlogo patch population


    【解决方案1】:

    可能有很多方法可以解决这个问题,但这里有两种选择。首先,我在 Esri Open 数据中找到的一些示例数据 - 2015 population data for Haiti。我将 shapefile 和相关文件提取到一个名为“gis”的文件夹中。我们将使用在 `gis:property-name': "POPULATION" 中找到的人口值。使用此设置:

    extensions [ gis ]
    
    globals [
      state-layer 
    ]
    
    to setup
      ca
      resize-world 0 110 0 80
      set-patch-size 6.5
      set state-layer gis:load-dataset "gis/Population_2015.shp"
      gis:set-world-envelope gis:envelope-of state-layer
      gis:set-drawing-color white
      gis:draw state-layer 1
      reset-ticks
    end
    

    第一种选择是在每个特征的质心处仅生成整个种群(在本例中,除以 1000 以不生成太多海龟)。

    to sprout-at-centroid
      foreach gis:feature-list-of state-layer [
        state ->
    
        ; Get the population for this state, divided by 1000
        ; to get a reasonable number
        let pop ( gis:property-value state "POPULATION" ) / 1000
    
        ; get the 'gis:location-of', an x-y list, for the 
        ; centroid of the current state / district
        let center gis:location-of gis:centroid-of state
    
        ; get the patch with the center xy values to sprout pop
        ask patch first center last center [
          sprout pop
        ]    
      ] 
    end
    

    输出如下所示:

    看起来不错!所有海龟都在每个要素的地理中心发芽。但是,根据您的数据集,您可能会遇到问题。请注意,中心的岛屿实际上是多部分要素的一部分,因此该多部分要素的人口已经在边界之外产生。这可能不会对您造成问题,具体取决于您所在地区的形状。

    选项 2 有点复杂,您可能会引入一些舍入误差。它也慢得多,并且根据您的世界和人口的大小可能需要很长时间/您可能会耗尽内存。首先,获取您的人口数量和您所在地区的补丁数量。然后,将人口除以该地区的斑块,得到每个斑块的平均人口。然后,让每个包含的补丁发芽那个数量的海龟:

    to apply-evenly
      foreach gis:feature-list-of state-layer [
        state ->
    
        ; Get the population for this state, divided by 10000
        ; to get a reasonable number
        let pop ( gis:property-value state "POPULATION" ) / 1000
    
        ; Get the patches contained by the state. This is slow!
        ; Using 'gis:intersecting' alone is much faster, but results
        ; in overlaps as geographic boundaries don't align with  patch boundaries
        let target-patches ( patches gis:intersecting state ) with [ gis:contained-by? self state ] 
    
        if any? target-patches [
    
          ; Get the number of turtles that should be in each target-patch:
          let avg-turtles round ( pop / count target-patches )
    
          ; Get the contained patches to sprout the appropriate number of turtles
          ask target-patches [
            sprout avg-turtles
          ]    
        ]
      ] 
    end
    

    这个的输出看起来像:

    但请注意,与我在此处作为示例使用的相比,更大的人口确实需要更长的时间,特别是因为我除以 1000。另外请注意,如果您的补丁太大而无法包含在某个地区,你的地区不会有任何海龟产卵(例如,南海岸附近的小岛)。

    希望这能让你指出正确的方向!

    【讨论】:

    • 我将您的 resize-world 0 110 0 80 增加到 0 250 0 210 并将您的 set-patch-size 6.5 减少到 2.5 。否则不会生成足够的代理。但我想这真的取决于你的目标以及你的人口数量需要有多精确
    • @HannahH。 - 这是有道理的,特别是如果你在谈论第二个选项 - 如果多边形不完全包含一个补丁,那么这个补丁将不会被计算在内,并且四舍五入也会引入一些错误。质心方法应该是精确的,因此如果您需要更多恒定值,您可以使用该方法,然后根据需要使用随机运动将海龟分布在整个区域中。顺便说一句-set-patch-size 不应该影响世界显示之外的任何东西-resize-world 应该就足够了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-30
    • 2016-03-28
    • 2020-07-22
    • 2019-09-02
    • 2016-03-11
    • 1970-01-01
    相关资源
    最近更新 更多