Is it possible to change the id attribute in a tag in simplekml?
import simplekml
kml = simplekml.Kml()
pnt = kml.newpoint(name='A Point')
pnt.coords = [(1.0, 2.0)]
kml.save("icon.kml")
This will generate the following document
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Folder id="2">
<Style id="5">
<IconStyle id="6">
<colorMode>normal</colorMode>
<scale>1</scale>
<heading>0</heading>
<Icon id="7">
<href>https://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png</href>
</Icon>
</IconStyle>
</Style>
<Placemark id="4">
<name>A Point</name>
<styleUrl>#5</styleUrl>
<Point id="3">
<coordinates>1.0,2.0,0.0</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
Note that in some tags, an id attribute appears as if it had been generated from some simplekml index. I needed to change the ID assigned to the <Style id="5">
tag to <Style id="icon-1532-0288D1-nodesc-normal">
This would change the icon on Google My Maps. How can I do this using simplekml?
It looks like in the (getting started) documentation, https://simplekml.readthedocs.io/en/latest/gettingstarted.html, the id tag is generated differently for different kinds of objects, ie 'feat_1', 'feat_2', 'geom_0':
This is what is generated:
I looked through the source code, and it looks like, at least in version 1.3.2, they got away from that, and generate tag id's by just counting up.
For some reason, these id tags are designed to be read only:
One hack-y way you could change this is something like (in base.py):
But that would set the same id for every object you have in your kml document:
Hopefully that helps your understanding. Not a full-stop answer, but too long to post in the comments.