Vector 根据病媒内的实际种群创造海龟
我想在NetLogo中创建一个群体。因此,我想根据该地区的人口在该地区创造海龟。然而,我并不完全确定如何做到这一点 我将该区域内的人口作为斑块值,如下所示:Vector 根据病媒内的实际种群创造海龟,vector,netlogo,patch,population,Vector,Netlogo,Patch,Population,我想在NetLogo中创建一个群体。因此,我想根据该地区的人口在该地区创造海龟。然而,我并不完全确定如何做到这一点 我将该区域内的人口作为斑块值,如下所示: gis:apply-coverage lor-dataset "GESBEV" population 但是当我用这个来创建人口时,我得到的是每个区域内的人口数量,而不是每个区域内的人口数量 每个地区是否有可能只获得一次人口值?如果有任何资料可以让我进一步阅读,我也将不胜感激。我自己还没有找到任何东西。可能有很多方法可以做到这一点,但这里有
gis:apply-coverage lor-dataset "GESBEV" population
但是当我用这个来创建人口时,我得到的是每个区域内的人口数量,而不是每个区域内的人口数量
每个地区是否有可能只获得一次人口值?如果有任何资料可以让我进一步阅读,我也将不胜感激。我自己还没有找到任何东西。可能有很多方法可以做到这一点,但这里有两种选择。首先,我在Esri Open data上找到了一些示例数据—。我将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。还要注意的是,如果你的补丁太大,以至于某个地区无法容纳,那么你的地区内将不会有海龟产卵(例如,南海岸的较小岛屿)
希望这能为你指明正确的方向 我将“调整世界大小”从0 110 0 80增加到0 250 0 210,并将设置的面片大小从6.5减小到2.5。否则,不会生成足够的代理。但我想这真的取决于你的目标和你的人口数量需要多精确be@HannahH. - 这是有道理的,特别是如果你在谈论第二个选项——如果多边形不完全包含一个面片,那么该面片将不会被计算在内,并且舍入也会引入一些错误。质心方法应该是精确的,所以如果你需要更多的常量值,你可以使用该方法,然后根据需要使用随机运动将你的海龟分布到各个地区。正如旁白-
设置补丁大小
不应影响世界显示之外的任何内容-调整世界大小
就足够了。