How to skip processing of invalid GPS coordinates when inverse geotagging to GPX

Started by dzeek, April 19, 2020, 08:03:21 AM

Previous topic - Next topic

dzeek

I'm using the ability of ExifTool to create GPX files from a geotagged video file. Some of the video files have invalid zero values for the coordinates. Is there a way to skip the processing of those coordinates? Here's the syntax I am currently using:

exiftool -ee -p gpx.fmt video.mp4 > video.gpx

where gpx.fmt contains the example at https://exiftool.org/geotag.html

Here's an example of the invalid GPS coordinates in one of the video files:

[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Date/Time: 2020:04:02 09:38:22.756646Z
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Measure Mode: Unknown (1)
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Latitude: 0 deg 0' 0.00" N
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Longitude: 0 deg 0' 0.00" E
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Altitude: 0 m
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Horizontal Accuracy: 0
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Vertical Accuracy: 0
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Velocity East: 0
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Velocity North: 0
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Velocity Up: 0
[MOV-Movie-Track-Media-MediaInfo-camm6] GPS Speed Accuracy: 0

Phil Harvey

Sure.  Change the IF line in gpx.fmt to this:

#[IF] ${gpslatitude#;$_ = undef if $_ == 0} ${gpslongitude;$_ = undef if $_ == 0}

This should skip the point if either latitude or longitude is zero.

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

dzeek

That works! Thank you. Could I ask where it is explained what expressions can be used? I looked and couldn't find it.

dzeek

Sorry. Nevermind. I found where it says "It may contain any valid Perl code"

Phil Harvey

Oops. Minor correction... I forgot a "#" to use the numerical value for the longitude:

#[IF] ${gpslatitude#;$_ = undef if $_ == 0} ${gpslongitude#;$_ = undef if $_ == 0}

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