0

我有一个 GeoJSON 功能集合,它只是旅行的线串。我想为每个功能添加列表和字典。添加到每个要素的数据对于每个要素都不同,但存储顺序与路径相同。如何将此数据作为属性添加到功能集?

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 成为上述功能集中的属性。

type(Trip_ID)
...list

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

谢谢!

4

1 回答 1

1

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

我会尝试过:

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

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

于 2018-10-14T06:05:28.057 回答