Skip to content

Instantly share code, notes, and snippets.

@javierwilson
Created February 27, 2012 03:06
Show Gist options
  • Save javierwilson/1921036 to your computer and use it in GitHub Desktop.
Save javierwilson/1921036 to your computer and use it in GitHub Desktop.
Reduce "resolucion" de un KML
#!/usr/bin/python
import re
f = open('municipio.kml', 'r')
line = f.readline()
while line:
rline = line.rstrip()
redata = re.match('<coordinates>(.*?)</coordinates>',line)
if redata:
rline = "<coordinates>"
data = redata.groups()
for datum in data:
coords = re.split(' ', datum)
i = 0
for acoord in coords:
if i % 2 == 0:
rline = rline + ' ' + acoord
i = i+1
rline = rline + "</coordinates>"
print rline
line = f.readline()
@javierwilson
Copy link
Author

Tal vez tambien debería reducir un par de decimales...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment