我正在使用库 simplekml 创建 kml。创建单个时,它就像一个魅力,但是当尝试为每个 dict 条目创建一个 kml 时,返回一个我找不到的错误。数据具有这种格式:
{12: {900: [(-5.4529673, 4.46),
(-3.4529799, 40.454),
(-3.495, 33),
(-3.45471, 40.437)]},
29: {900: [(-3.452....}
脚本如下所示:
import simplekml
kml = simplekml.Kml()
for key, value in data.items():
pol = kml.newpolygon(name = key)
pol.outerboundaryis = data[key][900]
pol.innerboundaryis = []
print(pol.outerboundaryis)
pol.style.linestyle.color = simplekml.Color.green
pol.style.linestyle.width = 5
pol.style.polystyle.color = simplekml.Color.changealphaint(100, simplekml.Color.green)
print(pol.name)
kml.save(str(pol.name) +".kml")
返回此错误:
AttributeError: 'int' object has no attribute 'count'
我一直在使用 kml.save('key' +".kml") 将边界转换为字符串......总是同样的问题。我不知道这一切中的 Int 是什么,我开始认为这是图书馆本身的问题?谢谢,麻烦您了
PE:还尝试遍历 enst dict,产生了相同的错误:
import simplekml
kml = simplekml.Kml()
for key, value in data.items():
for key2, value2 in value.items():
pol = kml.newpolygon(name = key)
pol.outerboundaryis = value2
pol.innerboundaryis = []
print(pol.outerboundaryis)
pol.style.linestyle.color = simplekml.Color.green
pol.style.linestyle.width = 5
pol.style.polystyle.color = simplekml.Color.changealphaint(100, simplekml.Color.green)
kml.save(str(pol.name) +".kml")