滑块更改 gis 数据
slider to change gis data
我目前有一个由四个 shp 文件组成的数据集 - 最低温度、最高温度、平均温度和降水量 - 文件的每个坐标。我试图解决的问题要求我应该能够在 运行 模型时动态更改这些变量。我正在考虑使用滑块,但我不确定是否可以使用滑块来更改 shapefile 值,而且我还在网上做了一些研究,但没有发现有人试图解决这个问题。
可以做我想做的事吗?
谢谢。
好的,所以在您的 setup
代码中,您可以读取 GIS 数据并为每个补丁分配四个属性。假设这些变量称为最低温度、最高温度、平均温度和降水量。所以你在顶部有一些这样的代码:
patches-own
[ min-temp
max-temp
mean-temp
precipitation
]
您可以创建额外的变量 - 所以用类似的东西替换它:
patches-own
[ min-temp-GIS
max-temp-GIS
mean-temp-GIS
precipitation-GIS
min-temp
max-temp
mean-temp
precipitation
]
将 GIS 数据集中的值分配给前四个变量。创建您的滑块(例如 max-temp-factor)并将以下内容添加到您的设置代码中。
to setup
... <all the code to import the values>
ask patches
[ set max-temp max-temp-GIS * max-temp-factor
... <same for other three variables>
]
...
end
现在补丁有两个值,你的滑块只是一个乘数(或者可以从 -10 到 +10 并增加温度等)这样你就可以有像 'what if there is a 20% lower precipitation' 或 'what if max temperature was 10 degrees higher'。 'addition' 因素的滑块默认值为 0,'multiplier' 因素的默认值为 1。
如果你想在模拟过程中改变这些值(所以第一年温度正常但后来升高),那么你需要在 go
步骤,以便它计算这些变量每个 tick
.
我目前有一个由四个 shp 文件组成的数据集 - 最低温度、最高温度、平均温度和降水量 - 文件的每个坐标。我试图解决的问题要求我应该能够在 运行 模型时动态更改这些变量。我正在考虑使用滑块,但我不确定是否可以使用滑块来更改 shapefile 值,而且我还在网上做了一些研究,但没有发现有人试图解决这个问题。 可以做我想做的事吗?
谢谢。
好的,所以在您的 setup
代码中,您可以读取 GIS 数据并为每个补丁分配四个属性。假设这些变量称为最低温度、最高温度、平均温度和降水量。所以你在顶部有一些这样的代码:
patches-own
[ min-temp
max-temp
mean-temp
precipitation
]
您可以创建额外的变量 - 所以用类似的东西替换它:
patches-own
[ min-temp-GIS
max-temp-GIS
mean-temp-GIS
precipitation-GIS
min-temp
max-temp
mean-temp
precipitation
]
将 GIS 数据集中的值分配给前四个变量。创建您的滑块(例如 max-temp-factor)并将以下内容添加到您的设置代码中。
to setup
... <all the code to import the values>
ask patches
[ set max-temp max-temp-GIS * max-temp-factor
... <same for other three variables>
]
...
end
现在补丁有两个值,你的滑块只是一个乘数(或者可以从 -10 到 +10 并增加温度等)这样你就可以有像 'what if there is a 20% lower precipitation' 或 'what if max temperature was 10 degrees higher'。 'addition' 因素的滑块默认值为 0,'multiplier' 因素的默认值为 1。
如果你想在模拟过程中改变这些值(所以第一年温度正常但后来升高),那么你需要在 go
步骤,以便它计算这些变量每个 tick
.