gpt4 book ai didi

javascript - 使用 geojson 确定给定地理区域与哪些其他地理区域共享边界

转载 作者:行者123 更新时间:2023-11-30 10:10:32 24 4
gpt4 key购买 nike

是否可以使用 topojson 或 geojson 来确定给定要素与哪些要素(即国家、州、市)共享边界?对于那些不熟悉 geojson 的人,数据结构如下所示:

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "01",
"properties": { "name": "Alabama" },
"geometry": {
"type": "Polygon",
"coordinates": [[[-87.359296,35.00118],
[-85.606675,34.984749],[-85.431413,34.124869],
[-85.184951,32.859696],[-85.069935,32.580372],
[-84.960397,32.421541],[-85.004212,32.322956],
[-84.889196,32.262709],[-85.058981,32.13674] …
]]
}
},
{
"type": "Feature",
"id": "02",
"properties": { "name": "Alaska" },
"geometry": {
"type": "MultiPolygon",
"coordinates": [[[[-131.602021,55.117982],
[-131.569159,55.28229],[-131.355558,55.183705],
[-131.38842,55.01392],[-131.645836,55.035827],
[-131.602021,55.117982]]],[[[-131.832052,55.42469],
[-131.645836,55.304197],[-131.749898,55.128935],
[-131.832052,55.189182], …
]]]
}
}
// ... more features ...
}

最佳答案

这里的问题与格式无关,但 TopoJSON 使这变得非常简单 - 实际上有一个库方法 topojson.neighbors(objects) ,它应该提供您所需要的:

Returns an array representing the set of neighboring objects for each object in the specified objects array. The returned array has the same number of elements as the input array; each element i in the returned array is the array of indexes for neighbors of object i in the input array. For example, if the specified objects array contains the features foo and bar, and these features are neighbors, the returned array will be [​1, [0]​], indicating that foo is a neighbor of bar and vice versa.

关于javascript - 使用 geojson 确定给定地理区域与哪些其他地理区域共享边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26935474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com