本文整理汇总了Python中pykml.factory.KML_ElementMaker.east方法的典型用法代码示例。如果您正苦于以下问题:Python KML_ElementMaker.east方法的具体用法?Python KML_ElementMaker.east怎么用?Python KML_ElementMaker.east使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pykml.factory.KML_ElementMaker
的用法示例。
在下文中一共展示了KML_ElementMaker.east方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_network_link_element
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
def create_network_link_element(name, kml_file, ts_obj):
lats, lons = flatten_lalos(None, ts_obj)
network_link = KML.NetworkLink(
KML.name(name),
KML.visibility(1),
KML.Region(
KML.Lod(
KML.minLodPixels(0),
KML.maxLodPixels(1800)
),
KML.LatLonAltBox(
KML.north(lats[-1] + 0.5),
KML.south(lats[0] - 0.5),
KML.east(lons[-1] + 0.5),
KML.west(lons[0] - 0.5)
)
),
KML.Link(
KML.href(kml_file),
KML.viewRefreshMode('onRegion')
)
)
return network_link
示例2: create_latlonalt_square
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
def create_latlonalt_square(north, south, west, east):
box = KML.LatLonAltBox(
KML.north(north),
KML.south(south),
KML.east(east),
KML.west(west),
)
#assert_valid(box)
return box
示例3: latlonbox
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
def latlonbox(self):
"""
lon_delta = 360.0 / (2**self.level)
lat_delta = 180.0 / (2**self.level)
west = -180 + self.col * lon_delta
east = west + lon_delta
north = 90 - lat_delta * self.row
south = north - lat_delta
"""
llbox = KML.LatLonBox(KML.north(self.north), KML.south(self.south), KML.east(self.east), KML.west(self.west))
assert_valid(llbox)
return llbox
示例4: main
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
#.........这里部分代码省略.........
except:
print '%%%%%%%%%%'
print 'Error:\nThe input file is not geocoded\n'
print '%%%%%%%%%%'
Usage();sys.exit(1)
#######################################################
################### Output KMZ ######################
############### Make PNG file
print 'Making png file ...'
length = data.shape[0]
width = data.shape[1]
try:fig_size
except:
fig_size_0 = 6.0 ## min figure dimension: 6.0
ratio = float(length)/float(width)
fig_size = [fig_size_0,fig_size_0*ratio]
print 'figure size: %.1f, %.1f'%(fig_size[0],fig_size[1])
ccmap = plt.get_cmap(color_map)
fig = plt.figure(figsize=fig_size,frameon=False)
ax = fig.add_axes([0., 0., 1., 1.])
ax.set_axis_off()
aspect = width/(length*1.0)
try: ax.imshow(data,aspect='auto',cmap=ccmap,vmax=Vmax,vmin=Vmin)
except: ax.imshow(data,aspect='auto',cmap=ccmap)
if disp_ref == 'yes':
try:
xref = int(atr['ref_x'])
yref = int(atr['ref_y'])
ax.plot(xref,yref,'ks',ms=ref_size)
print 'show reference point'
except: print 'Cannot find reference point info!'
ax.set_xlim([0,width])
ax.set_ylim([length,0])
figName = outName + '.png'
print 'writing '+figName
plt.savefig(figName, pad_inches=0.0, transparent=True, dpi=fig_dpi)
############### Making colorbar
pc = plt.figure(figsize=(1,8))
axc = pc.add_subplot(111)
if fig_unit in ['mm','mm/yr']: v_scale = 1000
elif fig_unit in ['cm','cm/yr']: v_scale = 100
elif fig_unit in ['m', 'm/yr']: v_scale = 1
norm = mpl.colors.Normalize(vmin=Vmin*v_scale, vmax=Vmax*v_scale)
clb = mpl.colorbar.ColorbarBase(axc,cmap=ccmap,norm=norm, orientation='vertical')
#clb.set_label(fig_unit)
clb.set_label(cbar_label+' ['+fig_unit+']')
clb.locator = ticker.MaxNLocator(nbins=cbar_bin_num)
clb.update_ticks()
pc.subplots_adjust(left=0.2,bottom=0.3,right=0.4,top=0.7)
pc.patch.set_facecolor('white')
pc.patch.set_alpha(0.7)
pc.savefig('colorbar.png',bbox_inches='tight',facecolor=pc.get_facecolor(),dpi=300)
############## Generate KMZ file
print 'generating kml file ...'
try: doc = KML.kml(KML.Folder(KML.name(atr['PROJECT_NAME'])))
except: doc = KML.kml(KML.Folder(KML.name('PySAR product')))
slc = KML.GroundOverlay(KML.name(figName),KML.Icon(KML.href(figName)),\
KML.altitudeMode('clampToGround'),\
KML.LatLonBox(KML.north(str(North)),KML.south(str(South)),\
KML.east( str(East)), KML.west( str(West))))
doc.Folder.append(slc)
#############################
print 'adding colorscale ...'
cb_rg = min(North-South, East-West)
cb_N = (North+South)/2.0 + 0.5*0.5*cb_rg
cb_W = East + 0.1*cb_rg
slc1 = KML.GroundOverlay(KML.name('colorbar'),KML.Icon(KML.href('colorbar.png')),\
KML.altitude('2000'),KML.altitudeMode('absolute'),\
KML.LatLonBox(KML.north(str(cb_N)),KML.south(str(cb_N-0.5*cb_rg)),\
KML.west( str(cb_W)),KML.east( str(cb_W+0.14*cb_rg))))
doc.Folder.append(slc1)
#############################
kmlstr = etree.tostring(doc, pretty_print=True)
kmlname = outName + '.kml'
print 'writing '+kmlname
kmlfile = open(kmlname,'w')
kmlfile.write(kmlstr)
kmlfile.close()
kmzName = outName + '.kmz'
print 'writing '+kmzName
cmdKMZ = 'zip ' + kmzName +' '+ kmlname +' ' + figName + ' colorbar.png'
os.system(cmdKMZ)
cmdClean = 'rm '+kmlname; print cmdClean; os.system(cmdClean)
cmdClean = 'rm '+figName; print cmdClean; os.system(cmdClean)
cmdClean = 'rm colorbar.png'; print cmdClean; os.system(cmdClean)
示例5: int
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
LAB = "%2.1e ug/m^3" % (MI_V+i*(MA_V-MI_V)/5)
POS_V = int(i*(LEGEND.size[1]- FONT.getsize("1")[1])/5)
DRAW_LAB.text((int(LEGEND.size[0]/4)+5, POS_V), LAB, font=FONT, fill='rgb(255, 255, 255)')
LEGEND.save(LEGEND_NAME + ".png")
#kml creation
MYKML = KML.kml()
DOC = KML.Document()
MYGO = KML.GroundOverlay(
KML.color('ffffffff'),
KML.Icon(KML.href(CODE_NAME + ".png")),
KML.LatLonBox(
KML.north(str(LATMAX/FRAC_LAT)),
KML.south(str(LATMIN/FRAC_LAT)),
KML.east(str(LONMAX/FRAC_LON)),
KML.west(str(LONMIN/FRAC_LON)),
KML.rotation('0')
)
)
MYSO = KML.ScreenOverlay(
KML.name('Legend'),
KML.Icon(KML.href(LEGEND_NAME + ".png")),
KML.overlayXY(x=".01",y=".99",xunits="fraction",yunits="fraction",),
KML.screenXY(x=".01",y=".99",xunits="fraction",yunits="fraction",),
KML.rotationXY(x="0.5",y="0.5",xunits="fraction",yunits="fraction",),
KML.size(x="0",y="0",xunits="pixels",yunits="pixels",)
)
DOC.append(MYSO)
DOC.append(MYGO)
示例6: create_regionalized_networklinks_file
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
def create_regionalized_networklinks_file(regions, ts_obj, box_list, lod, step, output_file):
## 1. Create directory to store regioalized KML data files
kml_data_files_directory = "kml_data_files"
links_directory = "{0}by{0}_links".format(step)
mkdir_kml_data_file_command = "mkdir {}".format(kml_data_files_directory)
os.system(mkdir_kml_data_file_command)
cmdDirectory = "cd {}; mkdir {}/".format(kml_data_files_directory, links_directory)
print("Creating KML links directory")
os.system(cmdDirectory)
## 2. Create master KML element and KML Document element
kml = KML.kml()
kml_document = KML.Document()
## 3. Define min and max levels of detail for large vs small data
min_lod = lod[0]
max_lod = lod[1]
## 4. Define list of regionalized boxes and list of number of regions
region_nums = list(range(0, len(regions)))
## 5. Generate a new network link element for each region
for ele in zip(regions, box_list, region_nums):
region_document = ele[0]
box = ele[1]
num = ele[2]
kml_file = "region_{}.kml".format(num)
## 5.1 Write the first region_document to a file and move it to the proper subdircetory
kml_1 = KML.kml()
kml_1.append(region_document)
print('writing ' + kml_file)
with open(kml_file, 'w') as f:
f.write(etree.tostring(kml_1, pretty_print=True).decode('utf-8'))
cmdMove = "mv {sm} {dir}/{sm}".format(sm=kml_file, dir="{}/{}".format(kml_data_files_directory, links_directory))
print("Moving KML Data Files to directory")
os.system(cmdMove)
## 5.2 Flatten lats and lons data
lats, lons = flatten_lalos(box, ts_obj)
## 5.3 Define new NetworkLink element
network_link = KML.NetworkLink(
KML.name('Region {}'.format(num)),
KML.visibility(1),
KML.Region(
KML.Lod(
KML.minLodPixels(min_lod),
KML.maxLodPixels(max_lod)
),
KML.LatLonAltBox(
KML.north(lats[0] + 0.5),
KML.south(lats[-1] - 0.5),
KML.east(lons[0] + 0.5),
KML.west(lons[-1] - 0.5)
)
),
KML.Link(
KML.href("{}/{}".format(links_directory, kml_file)),
KML.viewRefreshMode('onRegion')
)
)
## 5.4 Append new NetworkLink to KML document
kml_document.append(network_link)
## 6. Write the full KML document to the output file and move it to the proper directory
kml.append(kml_document)
with open(output_file, 'w') as f:
f.write(etree.tostring(kml, pretty_print=True).decode('utf-8'))
return "{}/{}".format(kml_data_files_directory, output_file), kml_data_files_directory
示例7: main
# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import east [as 别名]
#.........这里部分代码省略.........
except:
print "%%%%%%%%%%"
print "Error:\nThe input file is not geocoded\n"
print "%%%%%%%%%%"
Usage()
sys.exit(1)
#######################################################
################### Output KMZ ######################
############### Make PNG file
print "Making png file ..."
length = data.shape[0]
width = data.shape[1]
fig = plt.figure()
fig = plt.figure(frameon=False)
# fig.set_size_inches(width/1000,length/1000)
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
ax.set_axis_off()
fig.add_axes(ax)
aspect = width / (length * 1.0)
# ax.imshow(data,aspect='normal')
try:
ax.imshow(data, aspect="normal", vmax=Vmax, vmin=Vmin)
except:
ax.imshow(data, aspect="normal")
ax.set_xlim([0, width])
ax.set_ylim([length, 0])
# figName = k[0]+'.png'
figName = outName + ".png"
plt.savefig(figName, pad_inches=0.0, dpi=dpi)
# plt.show()
############### Making colorbar
pc = plt.figure(figsize=(1, 4))
axc = pc.add_subplot(111)
cmap = mpl.cm.jet
norm = mpl.colors.Normalize(vmin=Vmin * 1000, vmax=Vmax * 1000)
clb = mpl.colorbar.ColorbarBase(axc, cmap=cmap, norm=norm, orientation="vertical")
clb.set_label("mm/yr")
pc.subplots_adjust(left=0.25, bottom=0.1, right=0.4, top=0.9)
pc.savefig("colorbar.png", transparent=True, dpi=300)
############## Generate KMZ file
print "generating kml file"
doc = KML.kml(KML.Folder(KML.name("PySAR product")))
slc = KML.GroundOverlay(
KML.name(figName),
KML.Icon(KML.href(figName)),
KML.TimeSpan(KML.begin("2003"), KML.end("2010")),
KML.LatLonBox(KML.north(str(North)), KML.south(str(South)), KML.east(str(East)), KML.west(str(West))),
)
doc.Folder.append(slc)
#############################
print "adding colorscale"
latdel = North - South
londel = East - West
slc1 = KML.GroundOverlay(
KML.name("colorbar"),
KML.Icon(KML.href("colorbar.png")),
KML.altitude("9000"),
KML.altitudeMode("absolute"),
KML.LatLonBox(
KML.north(str(North - latdel / 2.0 + 0.5)),
KML.south(str(South + latdel / 2.0 - 0.5)),
KML.east(str(West - 0.2 * londel)),
KML.west(str(West - 0.4 * londel)),
),
)
doc.Folder.append(slc1)
#############################
from lxml import etree
kmlstr = etree.tostring(doc, pretty_print=True)
# kmlname=k[0]+'.kml'
kmlname = outName + ".kml"
print "writing " + kmlname
kmlfile = open(kmlname, "w")
kmlfile.write(kmlstr)
kmlfile.close()
# kmzName = k[0]+'.kmz'
kmzName = outName + ".kmz"
print "writing " + kmzName
# cmdKMZ = 'zip ' + kmzName +' '+ kmlname +' ' + figName
cmdKMZ = "zip " + kmzName + " " + kmlname + " " + figName + " colorbar.png"
os.system(cmdKMZ)
cmdClean = "rm " + kmlname
os.system(cmdClean)
cmdClean = "rm " + figName
os.system(cmdClean)
cmdClean = "rm colorbar.png"
os.system(cmdClean)