2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

めざせpythonライブラリマスター (65)geopy

Last updated at Posted at 2016-06-22

#【ライブラリ説明】
 住所→緯度経度 緯度経度→住所 変換ができる

#【プログラム】
 今回はvirtualenv上で実行したらUnicodeEncodeErrorが出たため、
 Anaconda2にダイレクトにpip installしました。
 ちなみにデフォルトエンコーディングをutf-8にしています。
  参考サイト→pythonのデフォルトエンコーディングをutf-8に変更する

# -*- coding: utf-8 -*-

from geopy.geocoders import Nominatim

geolocator = Nominatim()
location = geolocator.geocode("東京駅")
print (location.latitude, location.longitude)
# (35.68018575, 139.768196161308)

location = geolocator.reverse("35.68018575, 139.768196161")
print (location.address)
# 東京駅, 外堀通り, 中央区, 東京都, 100-6633, 日本

 ちなみに時々タイムアウトエラーがでます。

#【参考サイト】
 pypi
 github

2
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?