netlogo - Netlogo,在特定多边形的中心创建品种(即 id = 123456)
问题描述
我有一个 netlogo gis 模型。gis 形状文件由建筑物占地面积(以多边形的形式)组成。我想在特定建筑物的中心创建一个 id = "66445345"(多边形 id)的品种。没有大量的建筑物/多边形,但我只对在这个多边形上创建品种感兴趣任何想法如何做到这一点?
breed [blds bld]
set guo-building gis:load-dataset "guo-building.shp"
gis:drawing-color gray
gis:draw guo-buildings 1.0
foreach gis:vertex-list-of guo-buildings[
i ->
let bld-no gis:property-value i "id"
let center gis:centroid-of i
let center-location gis:location-of center
if bld-no = 66445345
[create-blds 1
[
set xcor (item 0 center-location)
set ycor (item 1 center-location)
set color red
set size 5
]
]
]
解决方案
对问题进行了排序。需要插入 blds-own 变量和存储 id。
breeds [blds bld]
breeds-own [building-no]
to setup-pma-locations
foreach gis:feature-list-of guo-buildings[
i ->
let bld-no gis:property-value i "ID"
let center gis:centroid-of i
let center-coordinates gis:location-of center
if not empty? center-coordinates [
create-blds 1
[
set xcor (item 0 center-coordinates)
set ycor (item 1 center-coordinates)
set color red
set size 0
set building-no bld-no ;store in blds-own variable
]
]
]
ask blds[
let pma blds with [building-no = "66445345"]
ask pma [set color red
set size 5]
]
推荐阅读
- python - 为我的 Mac 安装 psycopg2 时出错
- python - python setup.py build ctypes.CDLL:无法打开共享对象文件:没有这样的文件或目录
- ios - Xcode:点击自动填充后关闭键盘
- memory-management - gSOAP 客户端和服务器(尤其是服务器)中的简单内存管理
- java - Java“最简单”的地图实现/链接地图(NOT LinkedHashMap)
- python - 如何使 itertools.product() 随机
- flutter - 为什么 TextField 返回 null
- python-3.x - 最长公共子串python
- javascript - 如何在 React 中同步两个具有不同显示的下拉列表?
- snowflake-task - 如何计算最近一周的 AVG 时间戳