Skip to content

Instantly share code, notes, and snippets.

@Adrianod
Last active December 14, 2015 05:09
Show Gist options
  • Save Adrianod/5033553 to your computer and use it in GitHub Desktop.
Save Adrianod/5033553 to your computer and use it in GitHub Desktop.
Extract the KML polygons representing your LAS-order from Lantmäteriet.
import xml.etree.ElementTree as ET
tree = ET.parse('las.kml')
root = tree.getroot()[0]
for pm in root.findall('{http://www.opengis.net/kml/2.2}Placemark'):
if pm[0].text != "selected_square_style":
root.remove(pm)
else:
pm.remove(pm[0])
poly = pm[1]
poly.remove(poly[0])
poly.remove(poly[0])
poly.remove(poly[0])
tree.write('out.kml')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment