【发布时间】:2017-11-16 17:36:42
【问题描述】:
我有一个大的 geojson 文件,其一般结构如下:
{
"features": [{
"geometry": {
"coordinates": [
[
[-12.345, 26.006],
[-78.56, 24.944],
[-76.44, 24.99],
[-76.456, 26.567],
[-78.345, 26.23456]
]
],
"type": "Polygon"
},
"id": "Some_ID_01",
"properties": {
"parameters": "elevation"
},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[139.345, 39.2345],
[139.23456, 37.3465],
[141.678, 37.7896],
[141.2345, 39.6543],
[139.7856, 39.2345]
]
],
"type": "Polygon"
},
"id": "Some_OtherID_01",
"properties": {
"parameters": "elevation"
},
"type": "Feature"
}, {
"geometry": {
"coordinates": [
[
[143.8796, -30.243],
[143.456, -32.764],
[145.3452, -32.76],
[145.134, -30.87],
[143.123, -30.765]
]
],
"type": "Polygon"
},
"id": "Some_ID_02",
"properties": {
"parameters": "elevation"
},
"type": "Feature"
}
],
"type": "FeatureCollection"
}
我正在尝试删除重复的 ID,并保留最新版本(即 Some_ID_01 和 Some_ID_02 出于我的目的被认为是重复的,我想保留 Some_ID_02)。这些“重复”的内容没有任何顺序(尽管如果我可以在此过程中对它们进行排序,可能会按字母顺序排列,那就太好了),这些重复也不一定包含相同的坐标值(它们是较新版本的同一点)
到目前为止,我已经阅读了一些删除重复的 json 条目(特别是尝试从 this guide here 修改代码),但我不知道足够的 JS 来修改它以满足我的特定需求。我正在阅读 underscore.js 以查看是否有帮助(基于其他线程中的建议),并且还将查看 python 或 excel(作为 CSV 文件)以查看其中是否有任何简化。
是否可以将 geojson 输入到程序中并获得一个文件作为回报(即使它是一个文本文件)还是内联输入它会更简单?
【问题讨论】:
标签: javascript python excel duplicates geojson