from xml.dom import minidom
import simplekml
base = r"D:\数据治理\kml\1.kml"
kml = simplekml.Kml()
xmldoc = minidom.parse(base)
placemarks = xmldoc.getElementsByTagName(‘Placemark’)
for placemark in placemarks:
kml = simplekml.Kml()
name=placemark.getElementsByTagName(‘name’)[0].firstChild.data
polygon = [i.split(‘,’) for i in placemark.getElementsByTagName(‘coordinates’)[0].firstChild.data.strip().split(’ ‘)]
kml.newlinestring(name = name,description= ‘dsfdsa’ ,coords =polygon)
kml.save(base.repalce(’\1.kml’,‘’)+‘1/’+ name + ‘.kml’)
python拆分kml文件
于 2022-11-23 09:13:47 首次发布