Main Menu

KML file "corrupted"

Started by Manky, February 02, 2014, 05:01:40 PM

Previous topic - Next topic

Manky

Hi All,
I've used exiftool to successfully make a kml file with a single photo that does everything I need - it creates a little camera icon at the photo location which displays the photo when clicked. Perfect!
What I am now trying to do is create multiple kml files (one for each of the photos in a directory) in a single command so that I can then zip them all into a kmz.
I have gotten as far as writing the kml format code for all of the photos into a single kml file, but Google Earth apparently doesn't like that and gives me a "junk after document element" message.
So, my question is, how do I get exiftool to generate a separate kml file for each of the photos in a directory (without repeating the process x times)?
Thanks in advance!
Joe

Phil Harvey

Hi Joe,

I don't think that you really want a separate KML for each image.  Your problem is likely just a formatting error in the KML syntax.  Did you take a look at fmt_files/kml.fmt in the full ExifTool distribution?

If you really do want a separate KML for each image, the -w option will do this for you.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Manky

Thanks for your prompt response Phil!

Yes, it was a formatting problem - I was printing the entire kml.fmt file for each picture/placemark one after the other in the kml file instead of only printing the header and tail information only once.  I was under the impression that I needed a single kml file per picture that then needed to be zipped into a kmz, and didn't realise a single kml file could have multiple placemarks/photos.  I edited the file manually this time, but I found your instructions for making a batch file here http://cpanforum.com/posts/4346 so will have a crack at getting that running.

Thanks again!

Joe

Manky

Just an update Phil - the batch file combined with separate header, body and tail files to write the kml are working a treat!  Thanks so much for this software :D

Phil Harvey

I'm glad it is working, but those instructions are outdated.  Instead, this may be done by a single command.  See the comments in fmt_files/kml.fmt for details.  Also see here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).