Main Menu

Creating kml file

Started by PaulinAfrica, September 23, 2020, 09:37:23 AM

Previous topic - Next topic

PaulinAfrica

Good Morning from Sunny SA!
I suspect that my problem is more related to Windows than with ExifTool per se, please bear with me.

I have managed to extract GPS data from some photos in decimal degree format and exported to a text file using ExifTool, I can create a kml file using https://www.gpsvisualizer.com/ website, but I do understand that there's another way which I found on the forum https://exiftool.org/forum/index.php?topic=1688.0 and that's where I'm struggling.

I have created the relevant files (kml-start.fmt, kml-placemark.fmt, kml-end.fmt) by copying the text and inserting into notepad with the correct file extension. also created kml.bat replacing the default target C:\windows with my own. Not sure if I need to change anything in the .fmt files?

I have placed all the files including exiftool.exe into C:\Users\pauld\AppData\Local\Programs\ExifTool

When I drop a photo onto the .bat file I get the following error message:

The system cannot find the file specified.
The system cannot find the file specified.
done.
Press any key to continue . . .


It does output a kml file with the following:

C:\Users\pauld\AppData\Local\Programs\ExifTool\kml-placemark.fmt

So clearly I am doing something wrong, I have checked the naming which seems correct, but the system is unable to find the files?

Thanks in advance for your patience
Paul

StarGeek

Quote from: PaulinAfrica on September 23, 2020, 09:37:23 AM
I have managed to extract GPS data from some photos in decimal degree format and exported to a text file using ExifTool, I can create a kml file using https://www.gpsvisualizer.com/ website, but I do understand that there's another way which I found on the forum https://exiftool.org/forum/index.php?topic=1688.0 and that's where I'm struggling.

That post is part of the Archive and is very old and outdated.  Download the single kml.fmt file from GitHub and follow the instructions under InverseGeotagging.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

PaulinAfrica

Thanks for the information & links
Unfortunately I am still struggling, this is my inability to use the correct syntax for the command line and/or incorrect file structure.

I have copied the kml.fmt to notepad and saved as kml.fmt, do I need to do anything with the content of the file or should it be left as is?

I have opened a cmd prompt and entered the following: C:\Users\pauld\OneDrive\Desktop\Dwg Working Folder\How to>"C:\Users\pauld\OneDrive\Desktop\Dwg Working Folder\How to\20200916_085640.jpg" exiftool -p kml.fmt -r > out.kml

When I run this it brings up the image in windows photo viewer, creates a kmlfile, but the file is empty.

Please forgive my Noobness! When I do eventually get this right I will create a handholding step-by-step guide for dummies!

Thanks
Paul

StarGeek

You entered the jpg file as the program to run.  That's why the image viewer came up.  Exiftool must be the first thing on the line in order to run it.

Also, where is the kml.fmt located?  If it's not in the C:\Users\pauld\OneDrive\Desktop\Dwg Working Folder\How to directory, you need to put the full path to the file.

You also only had one file name, which would make a 1 location KML file.  If you want to use all the files in the How to while it is your current working directory, you can use a dot . for the directory name.  You also had the -r (-recurse) option.  Are there sub-directories you want to include?

CD back to the same directory and try this command, including the dot on the end.  This assumes the kml.fmt file is in that directory.  If not, use the full path to the kml.fmt file.
exiftool -p kml.fmt >out.kml .
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

PaulinAfrica

Thank you for your patience in resolving this issue.

My main problem was that I did not have file name extensions on, Doh!,so the kml.fmt file was actually kml.fmt.txt, which was never going to work; it is located in the source directory.

I was only using one file initially as a test, I should not have used the -r option, that was an error on my part.

It does now produce a kml file which opens in Google earth, but it does not display the image, as GE seemingly cannot locate the file.

The relevant output for the kml file from kml.fmt is         <description><![CDATA[<img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'> ]]>


And the subsequent properties from within GE for the out.kml file is <img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'>


If I add the image manually from within GE (Add local image) I get <img style="max-width:500px;" src="file:///C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg">

I then open out.kml in notepad and change the path to         <description><![CDATA[<img src='file:///C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'> ]]>


The subsequent properties from within GE for the updated out.kml file is then <img src='file:///C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'>


This then produces an image in GE and works as expected.

So, I'm not sure if the syntax needs updating for the kml.fmt file or if something has changed in Google Earth?

I am unsure as to what the correct syntax would be for the kml.fmt file in order to achieve the desired result with the correct path for GE to locate the file.

Thanks
Paul

PaulinAfrica

#5
As an addendum to the message above

When I use exiftool -p kml.fmt >out.kml . to select multiple images (4 in this case) the out.kml file produces 8 images, 4 of which cannot be viewed and 4 which can.

The second lot of images with the local path do not produce an image.



out.kml output <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
  <Document>
    <name>My Photos</name>
    <open>1</open>
    <Style id="Photo">
      <IconStyle>
        <Icon>
          <href>http://maps.google.com/mapfiles/kml/pal4/icon38.png</href>
          <scale>1.0</scale>
        </Icon>
      </IconStyle>
    </Style>
    <Folder>
      <name>.</name>
      <open>0</open>
      <Placemark>
        <description><![CDATA[<img src='./20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200916_085640.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5569492997222,-23.7140048997222,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='./20200916_091440.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200916_091440.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5449644,-23.7184992,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='./20200918_140533.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200918_140533.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5637092,-23.7083866,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='./20200918_151002.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200918_151002.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5871867,-23.7038732,0</coordinates>
        </Point>
      </Placemark>
    </Folder>
    <Folder>
      <name>C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to</name>
      <open>0</open>
      <Placemark>
        <description><![CDATA[<img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_085640.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200916_085640.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5569492997222,-23.7140048997222,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200916_091440.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200916_091440.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5449644,-23.7184992,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200918_140533.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200918_140533.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5637092,-23.7083866,0</coordinates>
        </Point>
      </Placemark>
      <Placemark>
        <description><![CDATA[<img src='C:/Users/pauld/OneDrive/Desktop/Dwg Working Folder/How to/20200918_151002.jpg'
          style='max-width:500px;max-height:500px;'> ]]>
        </description>
        <Snippet/>
        <name>20200918_151002.jpg</name>
        <styleUrl>#Photo</styleUrl>
        <Point>
          <altitudeMode>clampedToGround</altitudeMode>
          <coordinates>27.5871867,-23.7038732,0</coordinates>
        </Point>
      </Placemark>
    </Folder>
  </Document>
</kml>


Thanks
Paul

PaulinAfrica

Tried again this morning, everything is working perfectly well.

A little odd as I haven't changed anything, still not entirely sure why the output did what it did yesterday, but there you go.

One nice feature of doing things this way is that if you save the kml file from within GE save as.kmz, it automatically includes the photos as a stand alone package without any user involvement which can be handy if you have to distribute the file, but may need to reduce image sizes to keep the file size reasonable.

I'm not sure if there's code to reduce image sizes automatically, that would be quite handy :D

I will also look to include a R (route) flag to draw a line between images, probably with some dummy nodes in-between to take into account deviations/bends etc.

Thanks
Paul