Reputation: 215
I have a program that prints a pictures longitude and latitude. The program prints both of them into a format of: Degrees, minutes, seconds.
As I want to generate a KML file for GoogleEarth and GoogleEarth only supports decimal degrees, I need to think of a way of converting the coordinates.
Everytime I do the maths paper based, I get an incorrect answer. Could someone point out to me where Im going wrong.
I have the coordinates -
+51° 26' 13.57", -2° 34' 38.55"
I've been told to calculate it like this. Add 51 plus 26/60 plus 13.57/3600.
The correct answer should be -
51.437103, -2.577375
My next issue would be breaking down the string into the different segments as the metadata library I use prints the coordinates out as one individual string.
Upvotes: 2
Views: 2242
Reputation: 2051
The method you learned is fine, if you query google for (51+26/60+13.57/3600) you get (51.4371028), and same for -(2+34/60+38.55/3600), where you get (-2.577375). On some programming languages you have to be careful with /
which, when given integer parameters, truncs the result of the operation (in which case you want to cast the divisor or the dividend to floating point).
The part of breaking the string highly depends on which language you are working on/comfortable in.
Upvotes: 2