Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# colobar location
if loc.split()[0] == 'lower':
oy, sy = '0', '0'
elif loc.split()[0] == 'upper':
oy, sy = '1', '1'
if loc.split()[1] == 'left':
ox, sx = '0', '0'
elif loc.split()[1] == 'right':
ox, sx = '1', '1'
# generate KML screen overlay object
cbar_overlay = KML.ScreenOverlay(
KML.name('colorbar'),
KML.Icon(
KML.href("{}".format(os.path.basename(cbar_file))),
KML.viewBoundScale(0.75)
),
KML.overlayXY(x=ox, y=oy, xunits="fraction", yunits="fraction"),
KML.screenXY(x=sx, y=sy, xunits="fraction", yunits="fraction"),
KML.size(x="0", y="250", xunits="pixel", yunits="pixel"),
KML.rotation(0),
KML.visibility(1),
KML.open(0)
)
#print('add colorbar.')
return cbar_overlay
def writeKML(file, img, colorbarImg,inps):
South, North, West, East = get_lat_lon(file)
############## Generate kml file
print ('generating kml file')
doc = KML.kml(KML.Folder(KML.name(os.path.basename(file))))
slc = KML.GroundOverlay(KML.name(os.path.basename(img)),KML.Icon(KML.href(os.path.basename(img))),\
KML.TimeSpan(KML.begin(),KML.end()),\
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.ScreenOverlay(KML.name('colorbar'),KML.Icon(KML.href(os.path.basename(colorbarImg))),
KML.overlayXY(x="0.0",y="1",xunits="fraction",yunits="fraction",),
KML.screenXY(x="0.0",y="1",xunits="fraction",yunits="fraction",),
KML.rotationXY(x="0.",y="1.",xunits="fraction",yunits="fraction",),
KML.size(x="0",y="0.3",xunits="fraction",yunits="fraction",),
)
cb_img = "images"
cb_dir = os.path.join(fig_dir,cb_img)
shutil.rmtree(cb_dir,True)
os.mkdir(cb_dir)
cb_filename = "colorbarfig%s.png" % figno
try:
plotfigure.kml_colorbar(cb_filename)
shutil.move(cb_filename,cb_dir)
except:
print("KML ===> Warning : Something went wrong when creating colorbar")
# add link to KML file, even if colorbar didn't get created.
cb_str = os.path.join(cb_img,cb_filename)
colorbar = KML.ScreenOverlay(
KML.name("Colorbar"),
KML.Icon(KML.href(cb_str)),
KML.overlayXY(x="0.025", y="0.05", xunits="fraction", yunits="fraction"),
KML.screenXY(x="0.025", y="0.05",xunits="fraction", yunits="fraction"))
doc_fig.Document.append(colorbar)
# ----- Done with colorbar ------
# ------------------ done with fig/doc.kml file ------------------
fig_file = open(os.path.join(fig_dir,"doc.kml"),'wt')
fig_file.write('\n')
# In case we used CDATA in any snippets or descriptions. For some reason
# get converted to >tags<, which balloons don't translate.
kml_text = etree.tostring(etree.ElementTree(doc_fig),pretty_print=True).decode()
kml_text = kml_text.replace('>','>')
kml_text = kml_text.replace('<','<')
fig_file.write(kml_text)
KML.latitude(location['loc'].latitude),
KML.longitude(location['loc'].longitude),
KML.altitude(location['loc'].altitude),
),
KML.Orientation(
KML.heading(location['loc'].heading),
KML.tilt(-location['loc'].tilt),
KML.roll(location['loc'].roll),
),
KML.Scale(
KML.x(10),
KML.y(10),
KML.z(-10),
),
KML.Link(
KML.href('models/three_unit_lines.dae'),
)
)
)
return pm
def kml_overlay(self):
url = urlparse.urljoin( options.baseurl, '/'.join( str(t) for t in (self.level, self.col, self.row) ) + "."+self.filetype )
goverlay = KML.GroundOverlay()
goverlay.Region = self.kml_region()
goverlay.drawOrder = KML.drawOrder(self.level * DEFAULT_DRAW_ORDER_FACTOR)
goverlay.Icon = KML.Icon(KML.href(url))
goverlay.LatLonBox = self.latlonbox()
assert_valid(goverlay)
return goverlay
out_name_base = os.path.splitext(out_file)[0]
data_png_file = out_name_base + '.png'
print('writing {} with dpi={}'.format(data_png_file, inps.fig_dpi))
plt.savefig(data_png_file, pad_inches=0.0,
transparent=True, dpi=inps.fig_dpi)
# 2.3 Generate KML file
proj_name = metadata.get('PROJECT_NAME', 'InSAR_MintPy')
doc = KML.kml(KML.Folder(KML.name(proj_name)))
# Add data png file
img_name = os.path.splitext(os.path.basename(data_png_file))[0]
img = KML.GroundOverlay(
KML.name(img_name),
KML.Icon(
KML.href(os.path.basename(data_png_file))
),
KML.altitudeMode('clampToGround'),
KML.LatLonBox(KML.north(str(north)),
KML.east(str(east)),
KML.south(str(south)),
KML.west(str(west)))
)
doc.Folder.append(img)
# Add colorbar png file
cbar_file = '{}_cbar.png'.format(out_name_base)
cbar_overlay = generate_cbar_element(cbar_file,
vmin=inps.vlim[0],
vmax=inps.vlim[1],
unit=inps.disp_unit,
cmap=inps.colormap,
def write_kml(list_of_networks):
has_data = False
doc = KML.Document(
KML.name("PH5 Events"),
KML.Style(
KML.IconStyle(
KML.color('FF1400FF'),
KML.scale('1.25'),
KML.Icon(
KML.href(
'http://maps.google.com/mapfiles/' +
'kml/shapes/open-diamond.png')
)
),
id='star'
),
)
for network in list_of_networks:
network_folder = KML.Folder(KML.name(
"Network Code: " + str(network.code) +
" reportnum: " + network.reportnum))
for shot_line in network.shot_lines:
folder = KML.Folder(
KML.name("ShotLine " + str(shot_line.name[-3:])))
for shot in shot_line.shots: