How to convert degree minute second to degree decimal

后端 未结 6 2261
小鲜肉
小鲜肉 2021-02-07 13:37

I receive the latitude and longitude from GPS with this format:

Latitude : 78°55\'44.29458\"N

I need convert this data to:

latitude: 78.9288888889

<
6条回答
  •  醉话见心
    2021-02-07 13:57

    For multiple coordinates, you can read them in using pandas. Formatting is important - there should not be any white spaces. White spaces can be removed using the replace function. The outputs can be easily saved as a text file or spreadsheet. I just printed them for validation and rounded the decimals locations out to 4.

    ### read input file
    df = pd.read_excel('dms.xlsx')
    
    n = len(df)
    
    for i in range(n):
      Lat_d = round(parse_dms(df.Lat[i].replace(" ", "")),4)
      Long_d = round(parse_dms(df.Long[i].replace(" ", "")),4)
      print(Lat_d, Long_d)
    

提交回复
热议问题