Skip to content

Instantly share code, notes, and snippets.

@wulfgarpro
Last active February 21, 2016 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wulfgarpro/e1c49f4fd53ae0e48b2d to your computer and use it in GitHub Desktop.
Save wulfgarpro/e1c49f4fd53ae0e48b2d to your computer and use it in GitHub Desktop.
cgi script in python to generate kml LineString with LineStyle
#!/usr/bin/python
import random
lat_a = random.randrange(35, 40)
lon_a = random.randrange(-120, -112)
lat_b = random.randrange(35, 40)
lon_b = random.randrange(-120, -112)
kml = (
'<?xml version="1.0" encoding="UTF-8"?>'
'<kml xmlns="http://www.opengis.net/kml/2.2">'
' <Folder>'
' <Style id="SectionalRed">'
' <IconStyle>'
' <Icon>'
' </Icon>'
' </IconStyle>'
' <LabelStyle>'
' <color>ff0000ff</color>'
' </LabelStyle>'
' <LineStyle>'
' <color>ff0000ff</color>'
' <width>2.5</width>'
' </LineStyle>'
' </Style>'
' <Placemark>'
' <name>Random LineString with a Style</name>'
' <styleUrl>#SectionalRed</styleUrl>'
' <LineString>'
' <tessellate>1</tessellate>'
' <coordinates>'
' %d,%d,0'
' %d,%d,0'
' </coordinates>'
' </LineString>'
' </Placemark>'
' </Folder>'
'</kml>'
) % (lon_a,lat_a,lon_b,lat_b)
print 'Content-Type: application/vnd.google-earth.kml+xml\n'
print kml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment