質問

Googleマップは、このような10進表記の場所の緯度と長さを与えてくれます。

38.203655,-76.113281

それらを座標に変換するにはどうすればよいですか(程度、分、秒)

役に立ちましたか?

解決

38.203655は、学位の小数値です。 60分は、1分間で60分と60秒(1 degree == 60min == 3600S)です。

したがって、値の分数部分、つまり0.203655を取得し、60分、すなわち12.2193、12分である12.2193を取得し、数分の分数部分、すなわち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)

他のヒント

JavaScriptで他のジオ関連機能が必要な場合は、次のライブラリを使用できます。

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

次の機能を提供します。

  • DMSから10進緯度/経度変換
  • 距離計算
  • ベアリングの計算
  • 交差点の計算

トリックを行うPythonライブラリ:

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

これは解決策に役立つと思います。

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)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top