I'm creating kml using the library simplekml. When creating a single one, it works like a charm, but when trying to create one kml per dict entry, returns an error I could not locate. The data have this kind of format:
{12: {900: [(-5.4529673, 4.46),
(-3.4529799, 40.454),
(-3.495, 33),
(-3.45471, 40.437)]},
29: {900: [(-3.452....}
And the script looks like this:
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")
Returns this error:
AttributeError: 'int' object has no attribute 'count'
I've been converting the boundaries to strings, using kml.save('key' +".kml")...always the same problem. I don't know what is an Int in all this, I'm starting to thing this is a problem from the library itself? Please and thank you
P.E: Also tried iterating over the enst dict, yielded the same error:
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")
The issue is naming the polygon i.e pol = kml.newpolygon(name = key). Since the key is of type int it needs to be converted to string.
pol = kml.newpolygon(name = str(key))