2012-03-15 33 views
1

我試圖使GPS的感覺從EXIF標籤返回我的圖像座標:轉換GPS從理性的分數座標度

我的訪問爲座標

@property 
def GPSCoordinatesRat(self): 
coords = (str(self._EXIF_GPSLatitude) + 
      str(self._EXIF_GPSLongitude_Ref) + 
      str(self._EXIF_GPSLongitude)) + 
      str(self._EXIF_GPSLongitude_Ref) 

例如

>>> s.GPSCoordinatesRat 
'[Fraction(40, 1), Fraction(3901, 100), Fraction(0, 1)]W[Fraction(73, 1), Fraction(4691, 100), Fraction(0, 1)]W' 

我怎樣才能讓這個閱讀類似:

35° 42' 1" N, 71° 37' 0" W 

謝謝。

+0

你爲什麼要將所有東西都轉換成字符串? – 2012-03-15 03:17:38

+0

否則我得到一個TypeError:只能連接列表(不是「str」)到列表 – ensnare 2012-03-15 03:19:00

+0

所以這樣做它的人選應該是做錯了吧? o_O – 2012-03-15 03:20:51

回答

0

將每個Fraction傳遞給float構造函數將把它變成一個浮點數。這裏

>>> float(fractions.Fraction(3901, 100)) 
39.01