本文整理匯總了Python中simplekml.Kml.savekmz方法的典型用法代碼示例。如果您正苦於以下問題:Python Kml.savekmz方法的具體用法?Python Kml.savekmz怎麽用?Python Kml.savekmz使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類simplekml.Kml
的用法示例。
在下文中一共展示了Kml.savekmz方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: make_kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
def make_kml(llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat,
figs, colorbar=None, **kw):
"""TODO: LatLon bbox, list of figs, optional colorbar figure,
and several simplekml kw..."""
kml = Kml()
altitude = kw.pop('altitude', 1e0) #2e7)
roll = kw.pop('roll', 0)
tilt = kw.pop('tilt', 0)
altitudemode = kw.pop('altitudemode', AltitudeMode.relativetoground)
camera = Camera(latitude=np.mean([urcrnrlat, llcrnrlat]),
longitude=np.mean([urcrnrlon, llcrnrlon]),
altitude=altitude, roll=roll, tilt=tilt,
altitudemode=altitudemode)
kml.document.camera = camera
draworder = 0
for fig in figs: # NOTE: Overlays are limited to the same bbox.
draworder += 1
ground = kml.newgroundoverlay(name='GroundOverlay')
ground.draworder = draworder
ground.visibility = kw.pop('visibility', 1)
ground.name = kw.pop('name', 'overlay')
#ground.color = kw.pop('color', '9effffff') ##kw.pop('color', '9effffff')
ground.atomauthor = kw.pop('author', 'PyHum')
ground.latlonbox.rotation = kw.pop('rotation', 0)
ground.description = kw.pop('description', 'Matplotlib figure')
ground.gxaltitudemode = kw.pop('gxaltitudemode',
'clampToSeaFloor')
ground.icon.href = fig
ground.latlonbox.east = llcrnrlon
ground.latlonbox.south = llcrnrlat
ground.latlonbox.north = urcrnrlat
ground.latlonbox.west = urcrnrlon
if colorbar: # Options for colorbar are hard-coded (to avoid a big mess).
screen = kml.newscreenoverlay(name='ScreenOverlay')
screen.icon.href = colorbar
screen.overlayxy = OverlayXY(x=0, y=0,
xunits=Units.fraction,
yunits=Units.fraction)
screen.screenxy = ScreenXY(x=0.015, y=0.075,
xunits=Units.fraction,
yunits=Units.fraction)
screen.rotationXY = RotationXY(x=0.5, y=0.5,
xunits=Units.fraction,
yunits=Units.fraction)
screen.size.x = 0
screen.size.y = 0
screen.size.xunits = Units.fraction
screen.size.yunits = Units.fraction
screen.visibility = 1
kmzfile = kw.pop('kmzfile', 'overlay.kmz')
kml.savekmz(kmzfile)
示例2: make_kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
def make_kml(llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat,
figs, colorbar=None, times=None, **kw):
"""
TODO: LatLon bbox, list of figs, optional colorbar figure,
and several simplekml kw...
TJL - Obtained from
http://ocefpaf.github.io/python4oceanographers/blog/2014/03/10/gearth/
"""
if not SIMPLEKML_FLAG:
print '***ERROR!***'
print 'simplekml not installed, download from',\
'https://pypi.python.org/pypi/simplekml/'
return
kml = Kml()
altitude = kw.pop('altitude', 2e7)
roll = kw.pop('roll', 0)
tilt = kw.pop('tilt', 0)
altitudemode = kw.pop('altitudemode', AltitudeMode.relativetoground)
camera = Camera(latitude=np.mean([urcrnrlat, llcrnrlat]),
longitude=np.mean([urcrnrlon, llcrnrlon]),
altitude=altitude, roll=roll, tilt=tilt,
altitudemode=altitudemode)
kml.document.camera = camera
draworder = 0
for fig in figs: #NOTE: Overlays are limited to the same bbox.
draworder += 1
ground = kml.newgroundoverlay(name='GroundOverlay')
ground.draworder = draworder
ground.visibility = kw.pop('visibility', 1)
ground.name = kw.pop('name', 'overlay')
ground.color = kw.pop('color', '9effffff')
ground.atomauthor = kw.pop('author', 'ocefpaf')
ground.latlonbox.rotation = kw.pop('rotation', 0)
ground.description = kw.pop('description', 'Matplotlib figure')
ground.gxaltitudemode = kw.pop('gxaltitudemode',
'clampToSeaFloor')
if times:
ground.timespan.begin = times[0]
ground.timespan.end = times[1]
ground.icon.href = fig
#TJL - swapping west/east to match LL vs. UR properly
ground.latlonbox.west = llcrnrlon
ground.latlonbox.south = llcrnrlat
ground.latlonbox.north = urcrnrlat
ground.latlonbox.east = urcrnrlon
if colorbar: # Options for colorbar are hard-coded (to avoid a big mess).
screen = kml.newscreenoverlay(name='ScreenOverlay')
screen.icon.href = colorbar
screen.overlayxy = OverlayXY(x=0, y=0,
xunits=Units.fraction,
yunits=Units.fraction)
screen.screenxy = ScreenXY(x=0.015, y=0.075,
xunits=Units.fraction,
yunits=Units.fraction)
screen.rotationXY = RotationXY(x=0.5, y=0.5,
xunits=Units.fraction,
yunits=Units.fraction)
screen.size.x = 0
screen.size.y = 0
screen.size.xunits = Units.fraction
screen.size.yunits = Units.fraction
screen.visibility = 1
kmzfile = kw.pop('kmzfile', 'overlay.kmz')
kml.savekmz(kmzfile)
示例3:
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
# Style of the Track
trk.iconstyle.icon.href = ""
trk.labelstyle.scale = 1
trk.linestyle.width = 10
trk.linestyle.color = '7f00ff00' # aabbggrr
gps.iconstyle.icon.href = ""
gps.labelstyle.scale = 0
gps.linestyle.width = 4
gps.linestyle.color = '7fff0000'
# Saving
#kml.save("Extended-Kalman-Filter-CTRV.kml")
kml.savekmz("Extended-Kalman-Filter-CTRV-Adaptive.kmz")
# <codecell>
print('Exported KMZ File for Google Earth')
# <headingcell level=2>
# Screenshot
# <markdowncell>
# ![Google Earth](https://raw.github.com/balzer82/Kalman/master/Extended-Kalman-Filter-CTRV-Adaptive-Kurve.jpg)
# <markdowncell>
示例4:
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
# Style of the Track
trk.iconstyle.icon.href = ""
trk.labelstyle.scale = 1
trk.linestyle.width = 4
trk.linestyle.color = '7fff0000'
gps.iconstyle.icon.href = ""
gps.labelstyle.scale = 0
gps.linestyle.width = 3
gps.linestyle.color = '7fffffff'
# Saving
#kml.save("Extended-Kalman-Filter-CTRV.kml")
kml.savekmz("Extended-Kalman-Filter-CTRV.kmz")
# <codecell>
print('Exported KMZ File for Google Earth')
# <codecell>
# <codecell>
# <codecell>
示例5: main
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
#.........這裏部分代碼省略.........
Ellipsoids[i].rotate_eulerXY(math.pi,math.pi/2.)
if axes:
AxL[i].rotate_eulerXY(math.pi,math.pi/2.)
AxM[i].rotate_eulerXY(math.pi,math.pi/2.)
AxS[i].rotate_eulerXY(math.pi,math.pi/2.)
# Write .dae files ###############################
name='./'+Ellipsoids[i].name+'.dae'
c=colours(data['colour'][i])
t=(1.0)*data['transparency'][i].item()
write_collada_file(Ellipsoids[i].TP,
Ellipsoids[i].NP,
Ellipsoids[i].indices,
name,
c[0],c[1],c[2],t)
if axes:
write_collada_file(AxL[i].TP,
AxL[i].NP,
AxL[i].indices,
'./'+AxL[i].name+'.dae',
colours('black')[0],
colours('black')[1],
colours('black')[2],
0.0,
double_sided=True)
write_collada_file(AxM[i].TP,
AxM[i].NP,
AxM[i].indices,
'./'+AxM[i].name+'.dae',
colours('grey')[0],
colours('grey')[1],
colours('grey')[2],
0.0,
double_sided=True)
write_collada_file(AxS[i].TP,
AxS[i].NP,
AxS[i].indices,
'./'+AxS[i].name+'.dae',
colours('white')[0],
colours('white')[1],
colours('white')[2],
0.0,
double_sided=True)
# Create a KML document #########################
kml = Kml()
kml.document.name = "Ellipsoids"
for i in range(len(data)):
mod = kml.newmodel(altitudemode=AltitudeMode.relativetoground,
location='<longitude>'+repr(data['lon'][i])+'</longitude>'+
'<latitude>'+repr(data['lat'][i])+'</latitude>'+
'<altitude>'+repr(data['alt'][i])+'</altitude>',
visibility=1,
name=data['description'][i]
)
mod.link.href=('files/'+Ellipsoids[i].name+'.dae')
kml.addfile('./'+Ellipsoids[i].name+'.dae')
if axes:
modaxL = kml.newmodel(altitudemode=AltitudeMode.relativetoground,
location='<longitude>'+repr(data['lon'][i])+'</longitude>'+
'<latitude>'+repr(data['lat'][i])+'</latitude>'+
'<altitude>'+repr(data['alt'][i])+'</altitude>',
visibility=1,
name=data['description'][i]+'_axesL'
)
modaxL.link.href=('files/'+AxL[i].name+'.dae')
kml.addfile('./'+AxL[i].name+'.dae')
modaxM = kml.newmodel(altitudemode=AltitudeMode.relativetoground,
location='<longitude>'+repr(data['lon'][i])+'</longitude>'+
'<latitude>'+repr(data['lat'][i])+'</latitude>'+
'<altitude>'+repr(data['alt'][i])+'</altitude>',
visibility=1,
name=data['description'][i]+'_axesM'
)
modaxM.link.href=('files/'+AxM[i].name+'.dae')
kml.addfile('./'+AxM[i].name+'.dae')
modaxS = kml.newmodel(altitudemode=AltitudeMode.relativetoground,
location='<longitude>'+repr(data['lon'][i])+'</longitude>'+
'<latitude>'+repr(data['lat'][i])+'</latitude>'+
'<altitude>'+repr(data['alt'][i])+'</altitude>',
visibility=1,
name=data['description'][i]+'_axesS'
)
modaxS.link.href=('files/'+AxS[i].name+'.dae')
kml.addfile('./'+AxS[i].name+'.dae')
kml.savekmz(output)
if (nokeepfiles):
# Remove all intermediate Collada Files
for i in range(len(data)):
os.remove('./'+Ellipsoids[i].name+'.dae')
if axes:
for i in range(len(data)):
#os.remove('./'+ElAx[i].name+'.dae')
os.remove('./'+AxL[i].name+'.dae')
os.remove('./'+AxM[i].name+'.dae')
os.remove('./'+AxS[i].name+'.dae')
示例6: make_kml
# 需要導入模塊: from simplekml import Kml [as 別名]
# 或者: from simplekml.Kml import savekmz [as 別名]
def make_kml(extent,figs,colorbar=None, **kw):
"""
Parameters
----------
extent : tuple
(lm,lM,Lm,LM)
lower left corner longitude
upper right corner longitude
lower left corner Latitude
upper right corner Latitude
altitude : float
altitudemode :
roll : float
tilt : float
visibility : int
"""
lm = extent[0]
lM = extent[1]
Lm = extent[2]
LM = extent[3]
kml = Kml()
altitude = kw.pop('altitude', 2e6)
roll = kw.pop('roll', 0)
tilt = kw.pop('tilt', 0)
altitudemode = kw.pop('altitudemode', AltitudeMode.relativetoground)
camera = Camera(latitude = np.mean([Lm, LM]),
longitude = np.mean([lm, lM]),
altitude = altitude,
roll=roll,
tilt=tilt,
altitudemode=altitudemode)
kml.document.camera = camera
draworder = 0
for fig in figs: # NOTE: Overlays are limited to the same bbox.
draworder += 1
ground = kml.newgroundoverlay(name='GroundOverlay')
ground.draworder = draworder
ground.visibility = kw.pop('visibility', 1)
ground.name = kw.pop('name', 'overlay')
ground.color = kw.pop('color', '9effffff')
ground.atomauthor = kw.pop('author', 'author')
ground.latlonbox.rotation = kw.pop('rotation', 0)
ground.description = kw.pop('description', 'matplotlib figure')
ground.gxaltitudemode = kw.pop('gxaltitudemode', 'clampToSeaFloor')
ground.icon.href = fig
ground.latlonbox.east = lM
ground.latlonbox.south = Lm
ground.latlonbox.north = LM
ground.latlonbox.west = lm
if colorbar: # Options for colorbar are hard-coded (to avoid a big mess).
screen = kml.newscreenoverlay(name='ScreenOverlay')
screen.icon.href = colorbar
screen.overlayxy = OverlayXY(x=0, y=0,
xunits=Units.fraction,
yunits=Units.fraction)
screen.screenxy = ScreenXY(x=0.015, y=0.075,
xunits=Units.fraction,
yunits=Units.fraction)
screen.rotationXY = RotationXY(x=0.5, y=0.5,
xunits=Units.fraction,
yunits=Units.fraction)
screen.size.x = 0
screen.size.y = 0
screen.size.xunits = Units.fraction
screen.size.yunits = Units.fraction
screen.visibility = 1
kmzfile = kw.pop('kmzfile', 'overlay.kmz')
kml.savekmz(kmzfile)