"EXIF_GPSAltitude": "(220.279)",
"EXIF_GPSLatitude": "(55) (40.711) (0)",
"EXIF_GPSLatitudeRef": "N",
"EXIF_GPSLongitude": "(8) (30.2282) (0)",

How should i understand above example as degree, min, sec?

Some exif data that i extracted has metadata listed as above. Is these formats specified anywhere ? or should I expect alot of different formats of gps positions in EXIF?

I need to write a method that gives the lat,lng as decimal numbers based on exif data, and I am unsure about how many different formats I should expect to be able to parse(I will learn this over time) and this question is mostly about above examples. I know the degree is 55 and 8, but not sure if its 30 mins and 0.22*60 secs, and in that case, why is the 0 there?

  • What OS? You might be interested in exiftool sno.phy.queensu.ca/~phil/exiftool . There is an executable for Win or Mac that I've used successfully (Windows batchfiles in my case) to extract coordinate info from photos. – jbchurchill Feb 26 '15 at 20:36
  • 2
    What platform are you using to parse the information? What are you looking to convert it to? – Branco Feb 26 '15 at 20:38
  • I am converting to lat,lng decimal/double values and it was in C#. I simply needed the information that the answer gave. – Poul K. Sørensen Feb 26 '15 at 23:47
up vote 1 down vote accepted

According to this page, the latitude and longitude values could be in (1) degrees, (2) degrees and decimal minutes, or (3) degrees, minutes, and decimal seconds.

In your example, (2) is a decimal value and (3) is zero, so you have degrees, decimal minutes.

So, you'll have to some checks on the three values to determine which format is being used.

  • According to the exif standard, there are three "rational" fields for each, containing degrees, minutes, and seconds. exiftool normalizes imporoper decimal degrees into D,M,S while assigning these values, (exiftool -GPSLongitude="0.5 90 63.12345" junk.jpg" -> GPS Longitude: 2 deg 1' 3.12" W") So if you need decimal degrees, you do dd=x0+x1/60.+x2/3600. and could ignore the non-normalization. – Dave X Jan 13 '16 at 22:17

EXIF stores GPS coords as rational64u which is a list of six unsigned whole numbers in the following order:

[
   degreesNumerator, degreesDenominator, 
   minutesNumerator, minutesDenominator, 
   secondsNumerator, secondsDenominator
]

The format is consistent, and it looks like the tool you are using has already divided each pair into decimal numbers, so what you have is:

Lat: 55°   40.711' 0"
Lng:  8°  30.2282' 0"

If you want to convert to a single decimal number:

= Degrees + Minutes/60 + Seconds/3600

I used this batch file to get file names, date/time and decimal degree

positions.

**************start lalo.bat '-n forces signed decimal degrees exift -n d:\util\00ymp*.jpg >fud 'strfile one string per line (spaces ok) findstr /G:"strfile" fud >>fum **********end lalo.bat

produces output

File Name : 0104171345.jpg GPS Date/Time : 2017:01:04 21:45:19Z GPS Position : 46.9997367777778 -117.3392105 File Name : 0104171355.jpg GPS Date/Time : 2017:01:04 21:55:52Z GPS Position : 46.99622725 -117.307495111111 File Name : 0104171402.jpg GPS Date/Time : 2017:01:04 22:02:02Z GPS Position : 47.0075378333333 -117.284553527778 File Name : 0104171404.jpg GPS Date/Time : 2017:01:04 22:04:51Z GPS Position : 47.0222473055556 -117.275527944444 File Name : 0104171405.jpg GPS Date/Time : 2017:01:04 22:05:40Z GPS Position : 47.0269584444444 -117.269523611111

File Name : 0112171921.jpg File Name : 0112171921a.jpg File Name : 0112171921b.jpg File Name : 0120171623.jpg File Name : 0120171623a.jpg File Name : 0120171624.jpg

File Name : 0120171626.jpg GPS Date/Time : 2017:01:21 00:26:49Z GPS Position : 48.7900199722222 -117.290061944444 File Name : 0120171628.jpg GPS Date/Time : 2017:01:21 00:28:44Z GPS Position : 48.7907943611111 -117.292045583333

File Name : 0122170942.jpg File Name : 0122170942a.jpg File Name : 0122170948.jpg File Name : 0122170948a.jpg

File Name : 0122170950.jpg GPS Date/Time : 2017:01:22 17:50:12Z GPS Position : 48.7828292777778 -117.287322972222 File Name : 0122170950a.jpg GPS Date/Time : 2017:01:22 17:50:16Z GPS Position : 48.7828483333333 -117.287322972222 File Name : 0122170950b.jpg GPS Date/Time : 2017:01:22 17:50:38Z GPS Position : 48.7828178333333 -117.28733825

Thanks Jason for the formula to convert to decimal, and to https://stackoverflow.com/questions/45136895/extracting-gps-numerical-values-from-byte-array-using-powershell

function getGPS ($fullname) 
{
 'Fullname: ' + $fullname
 $imageProperties =New-Object -TypeName System.Drawing.Bitmap -ArgumentList $fullname
 if($imageProperties.PropertyItems|?{($_.id -eq 2) -or ($_.id -eq 4)}){
  [double]$LatDegrees = (([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 0)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 4)));
  [double]$LatMinutes = ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 8)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 12));
  [double]$LatSeconds = ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 16)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(2).Value, 20));
  [double]$LonDegrees = (([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 0)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 4)));
  [double]$LonMinutes = ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 8)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 12));
  [double]$LonSeconds = ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 16)) / ([System.BitConverter]::ToInt32( $imageProperties.GetPropertyItem(4).Value, 20));
  "Latitude: $LatDegrees;$LatMinutes;$LatSeconds"
  "Longitude: $LonDegrees;$LonMinutes;$LonSeconds"
  "DECLatitude: " + ([int]$LatDegrees +($LatMinutes/60) +($LatSeconds/60))
  "DECLongitude: " + ([int]$LonDegrees +($LonMinutes/60) +($LonSeconds/60))
}}

getGPS D:\pics\mypic.jpg

Fullname: P:\IMG_0014.JPG Latitude: 42;32.27;0 Longitude: 82;52.58;0 DECLatitude: 42.5378333333333 DECLongitude: 82.8763333333333

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.