I saw that no one mentioned this: https://pypi.python.org/pypi/LatLon/1.0.2
from fractions import Fraction from LatLon import LatLon, Longitude, Latitude latSigned = GPS.GPSLatitudeRef == "N" ? 1 : -1 longSigned = GPS.GPSLongitudeRef == "E" ? 1 : -1 latitudeObj = Latitude( degree = float(Fraction(GPS.GPSLatitude[0]))*latSigned , minute = float(Fraction(GPS.GPSLatitude[0]))*latSigned , second = float(Fraction(GPS.GPSLatitude[0])*latSigned) longitudeObj = Latitude( degree = float(Fraction(GPS.GPSLongitude[0]))*longSigned , minute = float(Fraction(GPS.GPSLongitude[0]))*longSigned , second = float(Fraction(GPS.GPSLongitude[0])*longSigned ) Coordonates = LatLon(latitudeObj, longitudeObj )
Now, using the Coordinates object, you can do what you want: Example:
(e.g. 46 ° 56'48 "N 7 ° 26'39" E from Wikipedia)
print Coordonates.to_string('d%°%m%′%S%″%H')
What you need to convert from ascii, and you did:
('5\xc2\xb052\xe2\x80\xb259.88\xe2\x80\xb3N', '162\xc2\xb04\xe2\x80\xb259.88\xe2\x80\xb3W')
and than print example:
print "Latitude:" + Latitude.to_string('d%°%m%′%S%″%H')[0].decode('utf8') >> Latitude: 5°52′59.88″N
Thanatos11th Dec 22 '16 at 21:00 2016-12-22 21:00
source share