在 netlogo 中使用 2 个地图
Using 2 maps in netlogo
是否可以在一个netlogo模型中使用两个贴图?如果是,如何合并或导入netlogo?
第一张地图有土地使用价值,第二张地图有土地价格价值。所以,我需要这两个属性来支持我的模型。
以下代码用于导入第一张地图;
to-report read-map[m]
let raster-map gis:load-dataset m
gis:load-dataset m
gis:set-world-envelope gis:envelope-of raster-map
report raster-map
end
to read-input-maps[m]
let data-source word"data/input/maps/" m
let input-map read-map data-source
gis:apply-raster input-map map-value
ask patches
[set map-value ifelse-value (map-value <= 0 or map-value >= 0)
[map-value]
[-9999]]
end
to read-map-attributes[m]
let data-source word "data/input/maps/"m
file-open data-source
set n-cols read-from-string remove "NCOLS"file-read-line
set n-rows read-from-string remove "NROWS" file-read-line
set xll read-from-string remove "XLLCORNER" file-read-line
set yll read-from-string remove "YLLCORNER" file-read-line
set cell-size read-from-string remove "CELLSIZE"file-read-line
file-close
resize-map
end
to resize-map
resize-world 0 n-cols 0 n-rows
set-patch-size 50 / cell-size
end
to display-map
ifelse input-file = "turi3400m2.asc"[
ask patches with[map-value = 1] [ set pcolor orange];Hutan sekunder orange
ask patches with[map-value = 2] [ set pcolor orange];Semak/belukar orange
ask patches with[map-value = 3] [ set pcolor yellow];Permukiman yellow
ask patches with[map-value = 4] [ set pcolor green];Kebun campuran green
ask patches with[map-value = 5] [ set pcolor green];Sawah green
ask patches with[map-value = 6] [ set pcolor orange];Tanah terbuka orange
ask patches with[map-value = 7] [ set pcolor green];Tegalan/ladang green
]
end
to setup-function [m]
read-map-attributes m
read-input-maps m
display-map
end
to setup
ca
setup-function
Input-File
请帮忙解决这个问题。
如何替换:
patches-own [map-value]
gis:apply-raster input-map map-value
与:
patches-own [map-value-1 map-value-2]
ifelse m = "..."
[ gis:apply-raster input-map map-value-1 ]
[ gis:apply-raster input-map map-value-2 ]
这是我能想到的最简单的修复方法。它是否适合您的用例?
是否可以在一个netlogo模型中使用两个贴图?如果是,如何合并或导入netlogo?
第一张地图有土地使用价值,第二张地图有土地价格价值。所以,我需要这两个属性来支持我的模型。
以下代码用于导入第一张地图;
to-report read-map[m]
let raster-map gis:load-dataset m
gis:load-dataset m
gis:set-world-envelope gis:envelope-of raster-map
report raster-map
end
to read-input-maps[m]
let data-source word"data/input/maps/" m
let input-map read-map data-source
gis:apply-raster input-map map-value
ask patches
[set map-value ifelse-value (map-value <= 0 or map-value >= 0)
[map-value]
[-9999]]
end
to read-map-attributes[m]
let data-source word "data/input/maps/"m
file-open data-source
set n-cols read-from-string remove "NCOLS"file-read-line
set n-rows read-from-string remove "NROWS" file-read-line
set xll read-from-string remove "XLLCORNER" file-read-line
set yll read-from-string remove "YLLCORNER" file-read-line
set cell-size read-from-string remove "CELLSIZE"file-read-line
file-close
resize-map
end
to resize-map
resize-world 0 n-cols 0 n-rows
set-patch-size 50 / cell-size
end
to display-map
ifelse input-file = "turi3400m2.asc"[
ask patches with[map-value = 1] [ set pcolor orange];Hutan sekunder orange
ask patches with[map-value = 2] [ set pcolor orange];Semak/belukar orange
ask patches with[map-value = 3] [ set pcolor yellow];Permukiman yellow
ask patches with[map-value = 4] [ set pcolor green];Kebun campuran green
ask patches with[map-value = 5] [ set pcolor green];Sawah green
ask patches with[map-value = 6] [ set pcolor orange];Tanah terbuka orange
ask patches with[map-value = 7] [ set pcolor green];Tegalan/ladang green
]
end
to setup-function [m]
read-map-attributes m
read-input-maps m
display-map
end
to setup
ca
setup-function
Input-File
请帮忙解决这个问题。
如何替换:
patches-own [map-value]
gis:apply-raster input-map map-value
与:
patches-own [map-value-1 map-value-2]
ifelse m = "..."
[ gis:apply-raster input-map map-value-1 ]
[ gis:apply-raster input-map map-value-2 ]
这是我能想到的最简单的修复方法。它是否适合您的用例?