本文整理匯總了Python中simplekml.Kml.newschema方法的典型用法代碼示例。如果您正苦於以下問題:Python Kml.newschema方法的具體用法?Python Kml.newschema怎麽用?Python Kml.newschema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類simplekml.Kml
的用法示例。
在下文中一共展示了Kml.newschema方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import newschema [as 別名]
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
示例2: write_track_kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import newschema [as 別名]
def write_track_kml(csvreader):
"""
Inputs: csv contains lon/lat
Output: glider track kml file
"""
coord = []
timerange = []
lat_f = int(cfg.get(section1, "LAT_COLUMN"))
lon_f = int(cfg.get(section1, "LON_COLUMN"))
date_f = int(cfg.get(section1, "DATE_COLUMN"))
date_fmt = cfg.get(section1, "DATE_FORMAT")
kml_dir = cfg.get(section1, "KML_DIR")
mission_date = cfg.get(section1, "MISSION_START_DATE")
organization = cfg.get(section1, "ORGANIZATION")
vehicle_name = cfg.get(section1, "VEHICLE_NAME")
kml_title = cfg.get(section1, "KML_DOC_TITLE")
kml_lookat_lon = float(cfg.get(section1, "KML_LOOKAT_LON"))
kml_lookat_lat = float(cfg.get(section1, "KML_LOOKAT_LAT"))
kml_lookat_range = float(cfg.get(section1, "KML_LOOKAT_RANGE"))
kml_cdata_title = cfg.get(section1, "KML_CDATA_TITLE")
plot_url = cfg.get(section1, "PLOT_URL")
plot_width = int(cfg.get(section1, "PLOT_WIDTH"))
plot_height = int(cfg.get(section1, "PLOT_HEIGHT"))
plot_temp = cfg.get(section1, "PLOT_TEMP")
plot_oxyg = cfg.get(section1, "PLOT_OXYG")
plot_sali = cfg.get(section1, "PLOT_SALI")
plot_chlo = cfg.get(section1, "PLOT_CHLO")
plot_cdom = cfg.get(section1, "PLOT_CDOM")
icon_url = cfg.get(section1, "ICON_URL")
icon_normal_scale = cfg.get(section1, "ICON_NORMAL_SCALE")
icon_normal_color = cfg.get(section1, "ICON_NORMAL_COLOR")
icon_normal_width = cfg.get(section1, "ICON_NORMAL_WIDTH")
icon_highlight_url = cfg.get(section1, "ICON_HIGHLIGHT_URL")
icon_highlight_scale = cfg.get(section1, "ICON_HIGHLIGHT_SCALE")
icon_highlight_color = cfg.get(section1, "ICON_HIGHLIGHT_COLOR")
icon_highlight_width = cfg.get(section1, "ICON_HIGHLIGHT_WIDTH")
path_line_color = cfg.get(section1, "PATH_LINE_COLOR")
path_line_width = int(cfg.get(section1, "PATH_LINE_WIDTH"))
csvheader = cfg.get(section1, "CSV_HEADER")
if csvheader == "YES":
csvreader.next()
else:
pass
for row in csvreader:
coord.append((row[lon_f - 1], row[lat_f - 1], 0.0)) # -1 for python order
timestamp = time.strptime(row[date_f - 1], date_fmt)
kmltime = time.strftime("%Y-%m-%dT%H:%M:%SZ", timestamp) # KML requires specific time format
timerange.append(kmltime) # time stamp
# This constructs the KML document from the CSV file.
kml = Kml(name="%s %s" % (organization, vehicle_name))
doc = kml.newdocument(name="%s" % kml_title, snippet=Snippet(timerange[0]))
doc.lookat.gxtimespan.begin = timerange[0]
doc.lookat.gxtimespan.end = timerange[-1]
doc.lookat.longitude = kml_lookat_lon
doc.lookat.latitude = kml_lookat_lat
doc.lookat.range = kml_lookat_range
# Create a folder
ge_dir = doc.newfolder(name="Tracks")
# Create a schema for extended data: heart rate, cadence and power
schema = kml.newschema()
# Create a new track in the folder
trk = ge_dir.newgxtrack(name="%s %s" % (organization, vehicle_name))
desc1 = "<![CDATA[\n%s<br />\n<br />\n" % kml_cdata_title
desc2 = "<a href='%s/glider.html' target='_blank'>Link to Plot</a><br />\n" % plot_url
desc_temp = "<img src='%s/%s' height='%d' width='%d' /><br />\n" % (plot_url, plot_temp, plot_height, plot_width)
desc_oxyg = "<img src='%s/%s' height='%d' width='%d' /><br />\n" % (plot_url, plot_oxyg, plot_height, plot_width)
desc_sali = "<img src='%s/%s' height='%d' width='%d' /><br />\n" % (plot_url, plot_sali, plot_height, plot_width)
desc_chlo = "<img src='%s/%s' height='%d' width='%d' /><br />\n" % (plot_url, plot_chlo, plot_height, plot_width)
desc_cdom = "<img src='%s/%s' height='%d' width='%d' /><br />\n" % (plot_url, plot_cdom, plot_height, plot_width)
desc3 = "]]>\n"
trk.description = desc1 + desc2 + desc_temp + desc_oxyg + desc_sali + desc_chlo + desc_cdom + desc3
# Apply the above schema to this track
trk.extendeddata.schemadata.schemaurl = schema.id
# Add all information to the track
trk.newwhen(timerange) # Each item in the give nlist will become a new <when> tag
trk.newgxcoord(coord) # Ditto
# Style
trk.stylemap.normalstyle.iconstyle.icon.href = icon_url
trk.stylemap.normalstyle.iconstyle.scale = icon_normal_scale
trk.stylemap.normalstyle.linestyle.color = icon_normal_color
trk.stylemap.normalstyle.linestyle.width = icon_normal_width
trk.stylemap.highlightstyle.iconstyle.icon.href = icon_highlight_url
trk.stylemap.highlightstyle.iconstyle.scale = icon_highlight_scale
trk.stylemap.highlightstyle.linestyle.color = icon_highlight_color
trk.stylemap.highlightstyle.linestyle.width = icon_highlight_width
# Create a path line
gpath = kml.newlinestring(name="%s %s" % (organization, vehicle_name))
gpath.description = trk.description
gpath.timespan.begin = timerange[0]
gpath.timespan.end = ""
gpath.coords = coord
gpath.style.linestyle.color = path_line_color
gpath.style.linestyle.width = path_line_width
#.........這裏部分代碼省略.........
示例3: Kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import newschema [as 別名]
kml = Kml(name="ExtendedData", open=1)
# Data Example---------------------------------------------------------------------------------------------------------
# Create and style a point
pnt = kml.newpoint(name='1. World of Birds (Data)', coords =[(18.361960,-34.016543)])
pnt.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/1.png'
# Add the Data to the point
pnt.extendeddata.newdata(name='birds', value=400, displayname="Bird Species")
pnt.extendeddata.newdata(name='aviaries', value=100, displayname="Aviaries")
pnt.extendeddata.newdata(name='visitors', value=10000, displayname="Annual Visitors")
# Simple Data Example -------------------------------------------------------------------------------------------------
# Create a schema
schema = kml.newschema(name='WOW')
schema.newsimplefield(name='birds', type='int', displayname='Bird Species')
schema.newsimplefield(name='aviaries', type='int', displayname='Aviaries')
schema.newsimplefield(name='visitors', type='int', displayname='Annual Visitors')
# Create and style a point
pnt = kml.newpoint(name='2. World of Birds (Simple Data)', coords =[(18.361960,-34.017224)])
pnt.iconstyle.icon.href = 'http://maps.google.com/mapfiles/kml/paddle/2.png'
# Uncomment the following line to display the data in a prettier format than the default table
#pnt.balloonstyle.text = """$[WOW/visitors] <b>$[WOW/visitors/displayName]</b> come to the World of Birds to walk through $[WOW/aviaries] <b>$[WOW/aviaries/displayName]</b> to see $[WOW/birds] <b>$[WOW/birds/displayName]</b>."""
# Add extended data to the point
pnt.extendeddata.schemadata.schemaurl = schema.id
pnt.extendeddata.schemadata.newsimpledata('birds', 400)
pnt.extendeddata.schemadata.newsimpledata('aviaries', 100)