My favorites | Sign in
Project Home Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# a Python script that uses pyKML to create a Hello World example
from lxml import etree
from pykml.factory import KML_ElementMaker as KML

text = 'Hello World!'
# create a document element with a single label style
kmlobj = KML.kml(
KML.Document(
KML.Style(
KML.LabelStyle(
KML.scale(6)
),
id="big_label"
)
)
)
# add placemarks to the Document element
for i in range(0,len(text)):
if text[i] != ' ':
kmlobj.Document.append(
KML.Placemark(
KML.name(text[i % len(text)]),
KML.styleUrl('#big_label'),
KML.Point(
KML.extrude(1),
KML.altitudeMode('relativeToGround'),
KML.coordinates('{lon},{lat},{alt}'.format(
lon=-70.0 + i*60.0/(len(text)-1),
lat=60.0,
alt=5000000,
),
),
),
)
)
print etree.tostring(etree.ElementTree(kmlobj),pretty_print=True)

Change log

c18d9f4ec8bb by taeri...@precisionm6500b on Dec 22, 2011   Diff
added a series of Hello World examples
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1134 bytes, 37 lines
Powered by Google Project Hosting