dictionary - 我找不到代码中缺少的内容,因此地图会更新
问题描述
我正在创建一个 netlogo 模型来研究对现有城市扩张景观的影响,该模型基于 5 年、1o 年和 15 年的预测......地图,它工作得很好,但是当试图将它合并到使用地图的版本中时,不同的投影不会更新,我找不到我错误地命名的东西......也许有人可以?
我首先在模型的简单版本中写的是:(cobertura-urbana 是一个选择器)
patches-own
[tipoDeUso]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
ca
setup-patches
reset-ticks
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup-patches
ask patches [set pcolor yellow]
ask n-of 250 patches [set pcolor orange]
ask n-of 350 patches [set pcolor lime]
ask n-of 450 patches with [pycor > 1] [ set pcolor green ]
ask n-of 150 patches with [pxcor >= round (max-pxcor / 2) and pycor < 0][set pcolor grey ]
ask n-of 150 patches with [pycor < 1 and pxcor > 0] [set pcolor lime]
ask n-of 25 patches with [ pxcor = 3] [set pcolor blue]
ask patches [initTipoDeUso]
initEscenarioCoberturaUrbana
ask patches [actualizarColor]
end
to initTipoDeUso
if pcolor = grey [ set tipoDeUso "Urbano"]
if pcolor = yellow [ set tipoDeUso "AgriculturaTemporal"]
if pcolor = lime [ set tipoDeUso "AgriculturaRiego"]
if pcolor = orange [ set tipoDeUso "Pastizal"]
if pcolor = green [ set tipoDeUso "Bosque" ]
if pcolor = blue [ set tipoDeUso "CuerposDeAgua"]
end
to initEscenarioCoberturaUrbana
if cobertura-urbana = "proyeccion-5" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.044 [
set tipoDeUso "Urbano"
]]]]
if cobertura-urbana = "proyeccion-10" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.088 [
set tipoDeUso "Urbano"
]]]]
if cobertura-urbana = "proyeccion-15" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.132 [
set tipoDeUso "Urbano"
]]]]
end
to actualizarColor
if tipoDeUso = "Urbano" [ set pcolor grey ]
if tipoDeUso = "AgriculturaTemporal" [ set pcolor yellow ]
if tipoDeUso = "AgriculturaRiego" [ set pcolor lime ]
if tipoDeUso = "Pastizal" [ set pcolor orange ]
if tipoDeUso = "Bosque" [ set pcolor green ]
if tipoDeUso = "CuerposDeAgua" [ set pcolor blue ]
end
然后我在包含实际地图的另一个模型中写的是:
extensions [ gis ]
patches-own [
TipoRaster
TipoDeUso ; Uso de suelo
]
globals [
raster-dataset
]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
ca
cargarMapa
reset-ticks
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;; PROCESOS SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to cargarMapa ;usa el mapa de uso de suelo elaborado por Urrutia-cardenas (2019)
set raster-dataset gis:load-dataset "/home/lorena/Documents/UNAM/Tesis/versiones de corrección/mapa_raster_final.asc"
gis:set-world-envelope ( gis:envelope-of raster-dataset )
gis:apply-raster raster-dataset TipoRaster
ask patches [initTipoDeUso]
initEscenarioCoberturaUrbana
ask patches [actualizarColor]
end
to initTipoDeUso
if tipoRaster = 0 [ set tipoDeUso "Nada" set pcolor black ]
if tipoRaster = 1 [ set tipoDeUso "Urbano" set pcolor gray]
if tipoRaster = 2 [ set tipoDeUso "AgriculturaTemporal" set pcolor yellow]
if tipoRaster = 3 [ set tipoDeUso "AgriculturaRiego" set pcolor lime ]
if tipoRaster = 4 [ set tipoDeUso "Pastizal" set pcolor orange ]
if tipoRaster = 5 [ set tipoDeUso "Bosque" set pcolor green ]
if tipoRaster = 6 [ set tipoDeUso "CuerposDeAgua" set pcolor sky]
if tipoRaster = 7 [ set tipoDeUso "Otros"]
end
to initEscenarioCoberturaUrbana
if cobertura-urbana = "proyeccion-5" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.044 [
set tipoDeUso "Urbano"
]]]]
if cobertura-urbana = "proyeccion-10" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.088 [
set tipoDeUso "Urbano"
]]]]
if cobertura-urbana = "proyeccion-15" [
ask patches with [tipoDeUso = "Urbano" and any? neighbors4 with [ tipoDeUso = "AgriculturaTemporal" or tipoDeUso = "AgriculturaRiego" or tipoDeUso = "Pastizal"]][
ask patches in-radius 1 [
if random-float 1.00 <= 0.132 [
set tipoDeUso "Urbano"
]]]]
end
to actualizarColor
if tipoDeUso = "Nada" [ set pcolor black ]
if tipoDeUso = "Urbano" [ set pcolor gray ]
if tipoDeUso = "AgriculturaTemporal" [ set pcolor yellow ]
if tipoDeUso = "AgriculturaRiego" [ set pcolor lime ]
if tipoDeUso = "Pastizal" [ set pcolor orange ]
if tipoDeUso = "Bosque" [ set pcolor green ]
if tipoDeUso = "CuerposDeAgua" [ set pcolor sky ]
if tipoDeUso = "Otros" [ set pcolor magenta + 1 ]
end