Main Menu

GPX error

Started by neil40, February 02, 2017, 12:39:30 PM

Previous topic - Next topic

neil40

Hi all,

Continuing on from my first Forum post, where I was copying data from JPG to RAF files, I have now come across a problem with Track files.

To step back one, my aim, as I don't have GPS in my camera, is to sort of 'reverse engineer', adding GPS points and locations to my picture files, and then to create a track file from them.

Using the Geotagging page examples, I seemed to create a KML track file OK, and Geosetter loads it successfully, showing the points (one side question is that from 600 pictures it only created about 300 points - why would that be?)

However, when using the GPX example, I get some [Minor] errors on creating the out.gpx file (Warning: [Minor] Tag 'gpsaltitude' not defined), which I read should be OK?
In Geosetter, when I try to load this out.gpx track file it tells me "The file "out.gpx" doesn't seem to be a valid GPS track file."

My command was exiftool -fileorder gpsdatetime -p gpx.fmt -d %Y-%m-%dT%H:%M:%SZ "E:\New England 2\2016-10-24" > out.gpx

A couple of other errors generated are as follows:
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool.exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool.exe

I have a copy of those executables in the same directory as the JPG's

Thanks for advice
Neil

Phil Harvey

#1
Hi Neil,

Quote from: neil40 on February 02, 2017, 12:39:30 PM
(one side question is that from 600 pictures it only created about 300 points - why would that be?)

only half the pictures had GPS data?

QuoteHowever, when using the GPX example, I get some [Minor] errors on creating the out.gpx file (Warning: [Minor] Tag 'gpsaltitude' not defined), which I read should be OK?

There you go.  And yes, the GPX file will not be valid format if some files are missing GPS.  If this is a possibility, you should add this to the command:

-if "$gpslatitude and $gpslongitude"

QuoteA couple of other errors generated are as follows:
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool.exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool.exe

You are somehow trying to read exiftool.exe as an input file, which is of course not what you want.  Did you perhaps use "*.*" on the command line?

- Phil

Edit: Strike out "*.*" comment -- it would just happen if the .exe was in the image file directory
...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 ($).

neil40

Ah, OK.
So, I moved the exiftool files out of the directory, and copied exiftool.exe to C:\Windows so it runs from there.
The GPX file is now created and opens in Geosetter.

As for the KML, it's running on the same files, all have GPS data. Commands and results:
exiftool -fileorder gpsdatetime -p gpx.fmt -d %Y-%m-%dT%H:%M:%SZ "E:\New England 2\2016-10-24" > out3.gpx
    1 directories scanned
  611 image files read

-- Geosetter tells me the track has 412 points

exiftool -p kml.fmt "E:\New England 2\2016-10-24" > out3.kml
    1 directories scanned
  611 image files read

-- Geosetter tells me this has 322 waypoints


I noticed on https://exiftool.org/geotag.html it says, at the bottom of the page, below the examples I followed for GPX and KML output:
QuoteThis example print format file is included in the "fmt_files" directory of the full ExifTool distribution

I can't find the full distribution though - the Windows zip only has the exe file in it.

[Edit] - scrub the last part, I found it's in the gz file and 7Zip will open that

Phil Harvey

Is geosetter right about the count?  What if you add the -if condition I mentioned? (although I don't expect this to help if you aren't getting any warnings).

If you were on a Mac or Linux system you could count the Placemarks in the KML file like this:

grep "<Placemark>" out.kml | wc -l

- 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 ($).

neil40

Quote from: Phil Harvey on February 02, 2017, 01:28:22 PM
Is geosetter right about the count?  What if you add the -if condition I mentioned? (although I don't expect this to help if you aren't getting any warnings).

If you were on a Mac or Linux system you could count the Placemarks in the KML file like this:

grep "<Placemark>" out.kml | wc -l

- Phil
This DOS command does the equivalent findstr -N "<Placemark>" out3.kml | find /c ":" and returned 611

Looking at the Track window in Geosetter it shows 322 Waypoints.
In the list of waypoints, I note it is missing Picture names
For example DSCF1307.jpg and 1308 have identical GPS points (take 2 pictures from the same spot, but different zoom)
Only 1307 is in the list of waypoints
Perhaps Geosetter is only showing the unique waypoints, as editing the KML file 1308 is there, as are the other 'missing' waypoints, which the count shows above

Phil Harvey

It seems my job is done. :)

- 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 ($).

neil40

#6
Quote from: Phil Harvey on February 02, 2017, 03:44:29 PM
It seems my job is done. :)

- Phil
Indeed. Thanks once again Phil.

I just loaded the KML into Google Earth and when I look at the points, they are all there.
However, when I click on an image, I just get a white box with the file name in it.
When I check properties of this, it shows the correct path to the file.
Have you seen this before?

[EDIT] I found this Google Earth (GE) forum post, relating to GE 6.1 (I have 7.1 and the same still seems true)
https://productforums.google.com/forum/#!topic/earth/HY-nZaJXKi0;context-place=topicsearchin/earth/exiftool

Initially it talks about changing a 'Local File' option which made no difference to me nor the person who posted the comment.
The 'fix' posted at the bottom worked for me in that instead of
<img src='f:/New England 2/2016-10-24/DSCF1307.JPG'
I changed it to this within GE
<img src='file:///f:/New England 2/2016-10-24/DSCF1307.jpg'
and the image then appeared.

Could I change the FMT file to accommodate this, as it is using a variable for the filename?

Phil Harvey

You should be able to change kml.fmt line from this

<img src='$directory/$filename'

to this

<img src='file:///$directory/$filename'

Although I don't know why you should need to.  It works fine on OS X without the file:///.

- 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 ($).

neil40

Thanks Phil,

I adjusted my fmt file to add the file:/// part in, and still it didn't work.

There is a clue in your kml.fmt sample
Quote#            3) Google Earth is picky about the case of the image file extension,
#               and may not be able to display the image if an upper-case
#               extension is used.

So, I used a bulk file rename program to rename all my pictures from .JPG to .jpg (takes seconds) and bingo, the KML file works.

Now I just need to figure out displaying the images in GE smaller as the fmt file pulls the original size out of the picture.

Almost there!

Phil Harvey

Right.

And I think that the "file:///" wouldn't have been necessary if you used relative paths as specified in note number 2 of kml.fmt.

You should be able to specify any ImageWidth/Height that you want.  For example, if you want half sized:

#[BODY]          width='${imagewidth;$_/=2}' height='${imageheight;$_/=2}'>

- 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 ($).

neil40

Quote from: Phil Harvey on February 03, 2017, 07:08:55 AM
Right.

And I think that the "file:///" wouldn't have been necessary if you used relative paths as specified in note number 2 of kml.fmt.

You should be able to specify any ImageWidth/Height that you want.  For example, if you want half sized:

#[BODY]          width='${imagewidth;$_/=2}' height='${imageheight;$_/=2}'>

- Phil

Fantastic.
My modified code, that uses the relative path and image size at a 1/4
#[BODY]      <Placemark>
#[BODY]        <description><![CDATA[<br/><table><tr><td>
#[BODY]        <img src='./$filename'
#[BODY]          width='${imagewidth;$_/=4}' height='${imageheight;$_/=4}'>
#[BODY]        </td></tr></table>]]></description>

One curiosity. Portrait style pictures that I have rotated manually in Windows, show in Landscape in GE!

Phil Harvey

Quote from: neil40 on February 03, 2017, 07:41:40 AM
One curiosity. Portrait style pictures that I have rotated manually in Windows, show in Landscape in GE!

It could be that Windows just changed the Orientation tag, and that GE ignores this tag.

BTW, you should use "$directory/$filename", not "./$filename" because the latter will work only if the directory you specify on the command line is ".".  (Again, use relative directory paths on the command line.)

- 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 ($).

neil40

Quote from: Phil Harvey on February 03, 2017, 08:01:58 AM
BTW, you should use "$directory/$filename", not "./$filename" because the latter will work only if the directory you specify on the command line is ".".  (Again, use relative directory paths on the command line.)
Ah, sorry, I misinterpreted where I was changing to a relative path! I changed the fmt file instead of the command line.  ::)

I'll scout around some GE forums to see what's going on with orientation.

Do you happen to know of a KML reference. I'd like to explore what else I could display on the pop up picture window, such as the co-ordinates and/or location from the data extracted from the picture.

Phil Harvey

...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 ($).

neil40