[GIS] How to parse EXIF GPS information to lat,lng decimal numbers

gps

"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?

Best Answer

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