Geometries¶
Point¶
-
class
simplekml.
Point
(extrude=None, altitudemode=None, gxaltitudemode=None, **kwargs)¶ A geographic location defined by lon, lat, and altitude.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] kml.save("Point.kml")
Styling a Single Point:
import simplekml kml = simplekml.Kml() pnt = kml.newpoint(name='A Point') pnt.coords = [(1.0, 2.0)] pnt.style.labelstyle.color = simplekml.Color.red # Make the text red pnt.style.labelstyle.scale = 2 # Make the text twice as big pnt.style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png' kml.save("Point Styling.kml")
Sharing a Style with many Points (Shared Style):
import simplekml kml = simplekml.Kml() style = simplekml.Style() style.labelstyle.color = simplekml.Color.red # Make the text red style.labelstyle.scale = 2 # Make the text twice as big style.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png' for lon in range(2): # Generate longitude values for lat in range(2): # Generate latitude values pnt = kml.newpoint(name='Point: {0}{0}'.format(lon,lat)) pnt.coords = [(lon, lat)] pnt.style = style kml.save("Point Shared Style.kml")
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
coords
¶ The coordinates of the feature, accepts list of tuples.
A tuple represents a coordinate in the order longitude then latitude. The tuple has the option of specifying a height. If no height is given, it defaults to zero. A point feature has just one point, therefore a list with one tuple is given.
- Examples:
- No height: [(1.0, 1.0), (2.0, 1.0)]
- Height: [(1.0, 1.0, 50.0), (2.0, 1.0, 10.0)]
- Point: [(1.0, 1.0)] # longitude, latitude
- Point + height: [(1.0, 1.0, 100)] # longitude, latitude, height of 100m
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
extrude
¶ Connect the Point to the ground, accepts int (0 or 1).
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
LinearRing¶
-
class
simplekml.
LinearRing
(coords=(), extrude=None, tessellate=None, altitudemode=None, gxaltitudemode=None, gxaltitudeoffset=None, **kwargs)¶ A closed line string, typically the outer boundary of a
simplekml.Polygon
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pol = kml.newpolygon() print pol.outerboundaryis # Shows that the outer boundary of a polygon is a linear ring pol.outerboundaryis.coords = [(0.0,0.0), (1.0,1.0), (2.0,2.0)] kml.save("LinearRing.kml")
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
coords
¶ The coordinates of the feature, accepts list of tuples.
A tuple represents a coordinate in the order longitude then latitude. The tuple has the option of specifying a height. If no height is given, it defaults to zero. A point feature has just one point, therefore a list with one tuple is given.
- Examples:
- No height: [(1.0, 1.0), (2.0, 1.0)]
- Height: [(1.0, 1.0, 50.0), (2.0, 1.0, 10.0)]
- Point: [(1.0, 1.0)] # longitude, latitude
- Point + height: [(1.0, 1.0, 100)] # longitude, latitude, height of 100m
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
extrude
¶ Connect the LinearRing to the ground, accepts int (0 or 1).
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxaltitudeoffset
¶ How much to offsets the LinearRing vertically, accepts int.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
tessellate
¶ Allows the LinearRing to follow the terrain, accepts int (0 or 1).
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
LineString¶
-
class
simplekml.
LineString
(extrude=None, tessellate=None, altitudemode=None, gxaltitudemode=None, gxaltitudeoffset=None, gxdraworder=None, **kwargs)¶ A connected set of line segments.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() ls = kml.newlinestring(name='A LineString') ls.coords = [(18.333868,-34.038274,10.0), (18.370618,-34.034421,10.0)] ls.extrude = 1 ls.altitudemode = simplekml.AltitudeMode.relativetoground kml.save("LineString.kml")
Styling:
import simplekml kml = simplekml.Kml() ls = kml.newlinestring(name='A LineString') ls.coords = [(18.333868,-34.038274,10.0), (18.370618,-34.034421,10.0)] ls.extrude = 1 ls.altitudemode = simplekml.AltitudeMode.relativetoground ls.style.linestyle.width = 5 ls.style.linestyle.color = simplekml.Color.blue kml.save("LineString Styling.kml")
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
coords
¶ The coordinates of the feature, accepts list of tuples.
A tuple represents a coordinate in the order longitude then latitude. The tuple has the option of specifying a height. If no height is given, it defaults to zero. A point feature has just one point, therefore a list with one tuple is given.
- Examples:
- No height: [(1.0, 1.0), (2.0, 1.0)]
- Height: [(1.0, 1.0, 50.0), (2.0, 1.0, 10.0)]
- Point: [(1.0, 1.0)] # longitude, latitude
- Point + height: [(1.0, 1.0, 100)] # longitude, latitude, height of 100m
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
extrude
¶ Connect the LinearRing to the ground, accepts int (0 or 1).
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxaltitudeoffset
¶ How much to offsets the LinearRing vertically, accepts int.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
gxdraworder
¶ The order to draw the linestring, accepts int.
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
tessellate
¶ Allowe the LinearRing to follow the terrain, accepts int (0 or 1).
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
Polygon¶
-
class
simplekml.
Polygon
(extrude=None, tessellate=None, altitudemode=None, gxaltitudemode=None, outerboundaryis=(), innerboundaryis=(), **kwargs)¶ A Polygon is defined by an outer boundary and/or an inner boundary.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() pol = kml.newpolygon(name='A Polygon') pol.outerboundaryis = [(18.333868,-34.038274), (18.370618,-34.034421), (18.350616,-34.051677),(18.333868,-34.038274)] pol.innerboundaryis = [(18.347171,-34.040177), (18.355741,-34.039730), (18.350467,-34.048388),(18.347171,-34.040177)] kml.save("Polygon.kml")
Styling:
import simplekml kml = simplekml.Kml() pol = kml.newpolygon(name='A Polygon') pol.outerboundaryis = [(18.333868,-34.038274), (18.370618,-34.034421), (18.350616,-34.051677),(18.333868,-34.038274)] pol.innerboundaryis = [(18.347171,-34.040177), (18.355741,-34.039730), (18.350467,-34.048388),(18.347171,-34.040177)] pol.style.linestyle.color = simplekml.Color.green pol.style.linestyle.width = 5 pol.style.polystyle.color = simplekml.Color.changealphaint(100, simplekml.Color.green) kml.save("Polygon Styling.kml")
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
extrude
¶ Connect the LinearRing to the ground, accepts int (0 or 1).
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
innerboundaryis
¶ The inner boundaries.
Accepts list of list of tuples of floats for multiple boundaries, or a list of tuples of floats for a single boundary.
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
outerboundaryis
¶ The outer boundary, accepts a list of tuples of floats.
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
tessellate
¶ Allows the Polygon to follow the terrain, accepts int (0 or 1).
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
MultiGeometry¶
-
class
simplekml.
MultiGeometry
(geometries=(), **kwargs)¶ MultiGeometry is a collection of simple features (Points, LineStrings, etc).
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() multipnt = kml.newmultigeometry(name="MultiPoint") for lon in range(2): # Generate longitude values for lat in range(2): # Generate latitude values multipnt.newpoint(coords=[(lon, lat)]) kml.save("MultiGeometry.kml")
Styling:
import simplekml kml = simplekml.Kml() multipnt = kml.newmultigeometry(name="MultiPoint") multipnt.style.labelstyle.scale = 0 # Remove the labels from all the points multipnt.style.iconstyle.color = simplekml.Color.red for lon in range(2): # Generate longitude values for lat in range(2): # Generate latitude values multipnt.newpoint(coords=[(lon, lat)]) kml.save("MultiGeometry Styling.kml")
-
address
¶ Standard address, accepts string.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
newgroundoverlay
(**kwargs)¶ Creates a new
simplekml.GroundOverlay
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.GroundOverlay
- Returns:
- an instance of
simplekml.GroundOverlay
- an instance of
-
newlinestring
(**kwargs)¶ Creates a new
simplekml.LineString
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.LineString
- Returns:
- an instance of
simplekml.LineString
- an instance of
-
newmodel
(**kwargs)¶ Creates a new
simplekml.Model
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.Model
- Returns:
- an instance of
simplekml.Model
- an instance of
-
newphotooverlay
(**kwargs)¶ Creates a new
simplekml.PhotoOverlay
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.PhotoOverlay
- Returns:
- an instance of
simplekml.PhotoOverlay
- an instance of
-
newpoint
(**kwargs)¶ Creates a new
simplekml.Point
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.Point
- Returns:
- an instance of
simplekml.Point
- an instance of
-
newpolygon
(**kwargs)¶ Creates a new
simplekml.Polygon
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.Polygon
- Returns:
- an instance of
simplekml.Polygon
- an instance of
-
newscreenoverlay
(**kwargs)¶ Creates a new
simplekml.ScreenOverlay
and attaches it to this MultiGeometry.The arguments are the same as
simplekml.ScreenOverlay
- Returns:
- an instance of
simplekml.ScreenOverlay
- an instance of
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
Model¶
-
class
simplekml.
Model
(altitudemode=None, gxaltitudemode=None, location=None, orientation=None, scale=None, link=None, resourcemap=None, **kwargs)¶ A 3D object described in a COLLADA file.
Arguments are the same as the properties.
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
link
¶ “A
simplekml.Link
class instance, acceptssimplekml.Link
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
location
¶ Position of the origin of the model, accepts
simplekml.Location
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
orientation
¶ The rotation on the model, accepts
simplekml.Orientation
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
resourcemap
¶ Used for mapping textures, accepts
simplekml.ResourceMap
-
scale
¶ “The scale of the model, accepts
simplekml.Scale
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
GxTrack¶
-
class
simplekml.
GxTrack
(extrude=None, altitudemode=None, gxaltitudemode=None, model=None, **kwargs)¶ A track describes how an object moves through the world over a given time period.
Arguments are the same as the properties.
Usage:
# This is a recreation of the example found in the KML Reference: # http://code.google.com/apis/kml/documentation/kmlreference.html#gxtrack import os from simplekml import Kml, Snippet, Types # Data for the track when = ["2010-05-28T02:02:09Z", "2010-05-28T02:02:35Z", "2010-05-28T02:02:44Z", "2010-05-28T02:02:53Z", "2010-05-28T02:02:54Z", "2010-05-28T02:02:55Z", "2010-05-28T02:02:56Z"] coord = [(-122.207881,37.371915,156.000000), (-122.205712,37.373288,152.000000), (-122.204678,37.373939,147.000000), (-122.203572,37.374630,142.199997), (-122.203451,37.374706,141.800003), (-122.203329,37.374780,141.199997), (-122.203207,37.374857,140.199997)] cadence = [86, 103, 108, 113, 113, 113, 113] heartrate = [181, 177, 175, 173, 173, 173, 173] power = [327.0, 177.0, 179.0, 162.0, 166.0, 177.0, 183.0] # Create the KML document kml = Kml(name="Tracks", open=1) doc = kml.newdocument(name='GPS device', snippet=Snippet('Created Wed Jun 2 15:33:39 2010')) doc.lookat.gxtimespan.begin = '2010-05-28T02:02:09Z' doc.lookat.gxtimespan.end = '2010-05-28T02:02:56Z' doc.lookat.longitude = -122.205544 doc.lookat.latitude = 37.373386 doc.lookat.range = 1300.000000 # Create a folder fol = doc.newfolder(name='Tracks') # Create a schema for extended data: heart rate, cadence and power schema = kml.newschema() schema.newgxsimplearrayfield(name='heartrate', type=Types.int, displayname='Heart Rate') schema.newgxsimplearrayfield(name='cadence', type=Types.int, displayname='Cadence') schema.newgxsimplearrayfield(name='power', type=Types.float, displayname='Power') # Create a new track in the folder trk = fol.newgxtrack(name='2010-05-28T01:16:35.000Z') # Apply the above schema to this track trk.extendeddata.schemadata.schemaurl = schema.id # Add all the information to the track trk.newwhen(when) # Each item in the give nlist will become a new <when> tag trk.newgxcoord(coord) # Ditto trk.extendeddata.schemadata.newgxsimplearraydata('heartrate', heartrate) # Ditto trk.extendeddata.schemadata.newgxsimplearraydata('cadence', cadence) # Ditto trk.extendeddata.schemadata.newgxsimplearraydata('power', power) # Ditto # Styling trk.stylemap.normalstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png' trk.stylemap.normalstyle.linestyle.color = '99ffac59' trk.stylemap.normalstyle.linestyle.width = 6 trk.stylemap.highlightstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png' trk.stylemap.highlightstyle.iconstyle.scale = 1.2 trk.stylemap.highlightstyle.linestyle.color = '99ffac59' trk.stylemap.highlightstyle.linestyle.width = 8 # Save the kml to file kml.save("GxTrack.kml")
-
address
¶ Standard address, accepts string.
-
altitudemode
¶ Specifies how the altitude for the Camera is interpreted.
Accepts
simplekml.AltitudeMode
constants.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Extra data for the feature.
-
extrude
¶ Connect the GxTrack to the ground, accepts int (0 or 1).
-
gxaltitudemode
¶ Specifies how the altitude for the Camera is interpreted.
With the addition of being relative to the sea floor. Accepts
simplekml.GxAltitudeMode
constants.
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
model
¶ A model to use on the track, accepts
simplekml.Model
New in version 1.2.1
-
name
¶ Name of placemark, accepts string.
-
newdata
(gxcoord, when, angle=None)¶ Creates a new gxcoord, when time and angle (if provided).
This is a convenience method for calling newwhen, newgxcoord and newangle. when and gxcoord are required, angle is optional.
-
newgxangle
(angle)¶ Creates a new gx:angle, accepts float or list of floats.
If one float is given a single angle entry is created, but if a list of floats is given, a angle entry is created for each float in the list.
-
newgxcoord
(coord)¶ Creates a gx:coord, accepts list of one tuples.
A gxcoord entry is created for every tuple in the list.
-
newwhen
(when)¶ Creates a new when time, accepts string or list of string.
If one string is given a single when entry is created, but if a list of strings is given, a when entry is created for each string in the list.
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-
GxMultiTrack¶
-
class
simplekml.
GxMultiTrack
(tracks=(), gxinterpolate=None, **kwargs)¶ A container for grouping gx:tracks.
Arguments are the same as the properties.
Usage:
import simplekml kml = simplekml.Kml() multitrack = kml.newgxmultitrack() track1 = multitrack.newgxtrack(name="track1") track2 = multitrack.newgxtrack(name="track2") kml.save("GxMultiTrack.kml")
-
address
¶ Standard address, accepts string.
Author of the feature, accepts string.
-
atomlink
¶ URL containing this KML, accepts string.
-
balloonstyle
¶ BalloonStyle of the feature, accepts
simplekml.BalloonStyle
-
camera
¶ Camera that views the scene, accepts
simplekml.Camera
-
description
¶ Description shown in the information balloon, accepts string.
-
extendeddata
¶ Short description of the feature, accepts
simplekml.Snippet
-
gxballoonvisibility
¶ Toggles visibility of a description balloon, accepts int 0 or 1
New in version 1.1.1
-
iconstyle
¶ IconStyle of the feature, accepts
simplekml.IconStyle
-
id
¶ The id string (read only).
-
labelstyle
¶ LabelStyle of the feature, accepts
simplekml.LabelStyle
-
linestyle
¶ LineStyle of the feature, accepts
simplekml.LineStyle
-
liststyle
¶ ListStyle of the feature, accepts
simplekml.ListStyle
-
lookat
¶ Camera relative to the feature, accepts
simplekml.LookAt
-
name
¶ Name of placemark, accepts string.
-
newgxtrack
(**kwargs)¶ Creates a new
simplekml.GxTrack
and attaches it to this mutlitrack.Returns an instance of
simplekml.GxTrack
class.- Args:
- Same as
simplekml.GxTrack
, except arguments that are not applicable in a multitrack grouping will be ignored, such as name, visibility, open, etc.
- Same as
-
phonenumber
¶ Phone number used by Google Maps mobile, accepts string.
-
placemark
¶ The placemark that contains this feature, read-only.
-
polystyle
¶ PolyStyle of the feature, accepts
simplekml.PolyStyle
-
region
¶ Bounding box of feature, accepts
simplekml.Region
-
snippet
¶ Short description of the feature, accepts
simplekml.Snippet
-
style
¶ The current style of the feature, accepts
simplekml.Style
-
stylemap
¶ The current StyleMap of the feature, accepts
simplekml.StyleMap
-
timespan
¶ Period of time, accepts
simplekml.TimeSpan
-
timestamp
¶ Single moment in time, accepts
simplekml.TimeStamp
-
visibility
¶ Whether the feature is shown, accepts int 0 or 1.
-
xaladdressdetails
¶ Address in xAL format, accepts string.
-