如何利用python批量读取多个json文件,并删除其中的重复点坐标?

  1. json 的数据格式如下所示: { "type": "Feature", "properties": { "MC": null, "PWH": null, "SJ": "2015", "YDDM": "S41"}, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 117.355254, 28.703052 ], [ 117.355254, 28.703052 ], [ 117.355250, 28.703018 ], [ 117.355246, 28.703002 ] ] ] } }
  2. 可以看到,geometry中的coordinates中,第一项坐标和第二项坐标是重复的,现在的需求就是删除第二个(任意一个)重复的坐标,使得coordinates中没有重复的点。
  3. 一个文件夹中有多个json,需要批量读取并删除。

c={ "type": "Feature", "properties": { "MC": null, "PWH": null, "SJ": "2015", "YDDM": "S41"}, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 117.355254, 28.703052 ], [ 117.355254, 28.703052 ], [ 117.355250, 28.703018 ], [ 117.355246, 28.703002 ] ] ]] } }
c['geometry']['coordinates'][0][0]=c['geometry']['coordinates'][0][0][:1]+c['geometry']['coordinates'][0][0][2:]

你的坐标项搞那么多层次干嘛?很容易出错

https://blog.csdn.net/weixin_44145300/article/details/90512158