Skip to content

Instantly share code, notes, and snippets.

@Th1sUs3rH4sN0N4m3
Created March 11, 2020 14:19
Show Gist options
  • Save Th1sUs3rH4sN0N4m3/5cd534c550af0007fd86971bdab191eb to your computer and use it in GitHub Desktop.
Save Th1sUs3rH4sN0N4m3/5cd534c550af0007fd86971bdab191eb to your computer and use it in GitHub Desktop.
Parse kml file
from fastkml import kml │
with open('/home/stytarenko/Downloads/test.kml', 'rb') as myfile: │
doc=myfile.read() │
k.from_string(doc) │
features = list(k.features()) │
l = []
for _doc in k.features():
for folder in _doc.features():
print(folder.name)
for item in folder.features():
# print(item.name)
if item.extended_data:
ext_data = item.extended_data
print(ext_data)
# print(item.description)
# coordinate = [str(item.geometry.x), str(item.geometry.y)]
# l.append([item.name, item.description, ','.join(coordinate)])
# with open('/ho', 'wb') as myfile:
# wr = csv.writer(myfile, quoting=csv.QUOTE_ALL)
# wr.writerow(mylist)
# f2 = list(features[0].features()) │
# features = list(k.features()) │
# f2 = list(features[0].features()) │
# f2 │
# f2[0] │
# f2[0].description │
# f2[0].name │
# f2[0].features() │
# list(f2[0].features()) │
# list(f2[0].features())[0] │
# f3 = list(f2[0].features())[0] │
# f3 │
# f3.name │
# f3.description │
# f3.address │
# f3.id │
# f3.geometry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment