使用 Python 向 GeoJSON 特征 Collection 中的特征添加属性

Add Properties to Features in GeoJSON Feature Collection with Python

我有一个 GeoJSON 功能 collection,它只是行程的线串。我想为每个功能添加列表和字典。添加到每个要素的数据因每个要素而异,但存储顺序与路线相同。如何将此数据作为属性添加到功能 Collection?

type(data)
>>> geojson.feature.FeatureCollection

data[1] #Example of what the data looks like
{'type': 'Feature',
 'geometry': {'type': 'LineString',
  'coordinates': [[-94.579644, 39.102126],
   [-64.579644, 29.102126],
   [-64.52684, 29.112103],
   [-64.52684, 29.112103]]},
 'properties': {'name': 'Route #1'}}

下面是我要添加的数据示例。我希望这次旅行的 Trip_ID 成为上面的功能 Collection 中的 属性。

type(Trip_ID)
...list

trip_id[1]
'149b16a4-f1ee-40ce-a165-5326196a1307'

谢谢!

如果我理解正确,您想将 Trip_ID 集合中的每个 ID 添加到 FeatureCollection 中的每个 Feature 对象。

我会尝试 :

for i in range(len(Trip_ID)):
    data[i].properties['id'] = Trip_ID[i]

注意:假设两个集合的大小和顺序相同。