[英]How to append properties to geojson file in python?
例如,我有具有如下功能的 geojson 文件。
{ "type": "FeatureCollection", "working_width": 20, "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 28.4766, 12.5645456 ] } } ]
如何將屬性添加到上述文件中,如下所示。
{ "type": "FeatureCollection", "working_width": 20, "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 28.4766, 12.5645456 ] }, "properties": { "fieldID": "2115145", "segmentId": "255c2s4c", "speed": 21.4586954, "elevation": 52.4586642, "time": "2018-05" } } ] }
數據結構只是一個普通的 python 字典,所以你可以像往常一樣更新它:
>>> geojson
{'type': 'FeatureCollection',
'working_width': 20,
'features': [{'type': 'Feature',
'geometry': {'type': 'Point',
'coordinates': [28.4766, 12.5645456]}}]}
>>> geojson['properties'] = {'fieldID': '2115145',
'segmentId': '255c2s4c',
'speed': 21.4586954,
'elevation': 52.4586642,
'time': '2018-05'}
>>> geojson
{'type': 'FeatureCollection',
'working_width': 20,
'features': [{'type': 'Feature',
'geometry': {'type': 'Point',
'coordinates': [28.4766, 12.5645456]}}],
'properties': {'fieldID': '2115145',
'segmentId': '255c2s4c',
'speed': 21.4586954,
'elevation': 52.4586642,
'time': '2018-05'}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.