A snippet, not big enough for a blog..
"""
Script: kmz_kml.py
Author:
Dan.Patterson@carleton.ca
References: many
Purpose: convert kmz to kml base script
"""
import zipfile
from xml.dom import minidom
def kmz_to_kml(fname):
"""save kmz to kml"""
zf = zipfile.ZipFile(fname,'r')
for fn in zf.namelist():
if fn.endswith('.kml'):
content = zf.read(fn)
xmldoc = minidom.parseString(content)
out_name = (fname.replace(".kmz",".kml")).replace("\\","/")
out = open(out_name,'w')
out.writelines(xmldoc.toxml())
out.close()
else:
print("no kml file")
if __name__ == "__main__":
fname = r"Drive:\Your_Path_here\GIS_central.kmz"
kmz_to_kml(fname)
File for testing attached... just a simple bookmark
This document was generated from the following discussion: convert *.kmz to *.kml