Reputation: 311
For example i have geojson file with features as shown below.
{ "type": "FeatureCollection", "working_width": 20, "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 28.4766, 12.5645456 ] } } ]
How to add the properties to this above file as shown below.
{ "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" } } ] }
Upvotes: 4
Views: 1657
Reputation: 2691
The data structure is just a regular python dictionary so you can update it as normal:
>>> 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'}}
Upvotes: 4