Sam*_*mar 5 python dictionary geojson data-structures
我有以下字典(Geojson):
'properties': {
            'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m',
'time': '2000-01-31'
    }
通过将某些值移动到属性中的新键,将是最简单的方法如下。
'properties': {
        'style': {
            'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m'
        },
        'time': '2000-01-31'
    }
}
任何反馈将有所帮助。谢谢。
你可以弹出并构建一个新的字典,time如下所示:
properties = {
            'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff',
'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m',
'time': '2000-01-31'
    }
time = properties.pop('time')
new_properties = {'style': properties, 'time':time}
print(new_properties)
# {'style': {'fill': '#ffffff', 'fill-opacity': 1, 'stroke': '#ffffff', 
#            'stroke-opacity': 1, 'stroke-width': 1.5, 'title': '0.00 m'},
#   'time': '2000-01-31'}
| 归档时间: | 
 | 
| 查看次数: | 58 次 | 
| 最近记录: |