AnsweredAssumed Answered

Create KML with Embedded Image

Question asked by mitchh300 on Nov 16, 2017
Latest reply on Nov 17, 2017 by mitchh300

I am trying to recreate/customize a tool (found here) which reads metadata from a JPG and creates a KML from it.  The KML points to the relative path of the JPG and the image is displayed in the KML's pop-up window.  

 

I cannot get the image to show up and was hoping someone had an idea.  The image below shows what the KML looks like in Google Earth. 

 

Here is the code that produces the KML. 

for directory, sub, files in os.walk(imageDir):
    for f in files:
        fullpath = os.path.join(directory, f)
        relpath = os.path.relpath(fullpath) #I've tried passing both fullpath and relpath to Text below
       
        data = get_exif_data(fullpath)
        c = get_lat_lon(data)
        coordinates = (c[1],c[0])
       
        pnt = kml.newpoint(name=f, coords = [coordinates])
       
        imgHeight = data['ImageLength']/4
        imgWidth = data['ImageWidth']/4
        project = 'Test'
        date = data['DateTime']
        device = 'Apple iPhone'
       
        Text = '<img src="'+relpath+'" alt="path failed" width="{0}" height="{1}"'+\
                'align="left"/>'.format(imgWidth, imgHeight)+\
                '<br>Project Name: {0}'+\
                '<br>Capture Date & Time: {1}<br>Device: {2}'.format(project, date, device)
       
        pnt.style.iconstyle.icon.href ="http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png"
       
kml.save(outKML)

 

Any ideas as to why this is happening.  I'm 99% sure the path to the image is incorrect, but I'm out of ideas. 

Outcomes