Convert DD (decimal degrees) to DMS (degrees minutes seconds) in Python?

后端 未结 9 1966
花落未央
花落未央 2020-12-05 19:53

How do you convert Decimal Degrees to Degrees Minutes Seconds In Python? Is there a Formula already written?

9条回答
  •  清歌不尽
    2020-12-05 20:01

    Now we can use LatLon library...

    https://pypi.org/project/LatLon/

    >> palmyra = LatLon(Latitude(5.8833), Longitude(-162.0833)) # Location of Palmyra Atoll in decimal degrees
    >> palmyra = LatLon(5.8833, -162.0833) # Same thing but simpler! 
    >> palmyra = LatLon(Latitude(degree = 5, minute = 52, second = 59.88),
                         Longitude(degree = -162, minute = -4.998) # or more complicated!
    >> print palmyra.to_string('d% %m% %S% %H') # Print coordinates to degree minute second
    ('5 52 59.88 N', '162 4 59.88 W')`
    

提交回复
热议问题