【问题标题】:Lat Long to Minutes and Seconds?经纬度长到分和秒?
【发布时间】:2011-01-04 15:10:33
【问题描述】:

Google 地图以十进制表示法为我提供位置的纬度和经度,如下所示:

38.203655,-76.113281

如何将这些转换为坐标(度、分、秒)

【问题讨论】:

标签: latitude-longitude degrees seconds


【解决方案1】:

38.203655 是十进制的度数。有 60 分钟是一个度,一分钟有 60 秒(1 度 == 60 分钟 == 3600 秒)。

所以取值的小数部分,即 0.203655,乘以 60 得到分钟,即 12.2193,即 12 分钟,然后重复分钟的小数部分,即 0.2193 = 13.158000 秒。

python中的示例:

def deg_to_dms(deg):
    d = int(deg)
    md = abs(deg - d) * 60
    m = int(md)
    sd = (md - m) * 60
    return [d, m, sd]

print deg_to_dms(38.203655)
print deg_to_dms(-76.113281)

【讨论】:

  • 很好的解决方案。小提示:通常对于 DMS 格式,它没有签名,而是使用基本方向(即,不是 -76 12 34.567 而是 W76 12 34.567)。
【解决方案2】:

如果您需要 JavaScript 中的其他地理相关功能,您可以使用以下库

http://www.movable-type.co.uk/scripts/latlong.html

它提供以下功能:

  • DMS 从/到十进制纬度/经度转换
  • 距离计算
  • 方位计算
  • 交点计算

【讨论】:

    【解决方案3】:

    解决问题的 Python 库:

    https://pypi.python.org/pypi/LatLon/1.0.2

    【讨论】:

      【解决方案4】:

      我认为这将帮助您解决问题:

      def deg_min_sec(self,degrees=0.0):
              if type(degrees) != 'float':
                  try:
                      degrees = float(degrees)
                  except:
                      print '\nERROR: Could not convert %s to float.' % (type(degrees))
                      return 0
              minutes = degrees % 1.0 * 60
              seconds = minutes % 1.0 * 60
      
              return (degrees, minutes, seconds)
      

      【讨论】:

        猜你喜欢
        • 2011-12-17
        • 1970-01-01
        • 2016-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-01-11
        • 1970-01-01
        • 2013-09-09
        相关资源
        最近更新 更多