Created
November 13, 2020 10:49
-
-
Save lightondust/734f74be00cc79a152613d5c8b66eab7 to your computer and use it in GitHub Desktop.
get coordinate from address
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import lxml | |
def get_coordinate_of_address(address): | |
url = 'http://geocode.csis.u-tokyo.ac.jp/cgi-bin/simple_geocode.cgi?charset=UTF8&addr={}'.format(address) | |
res = requests.get(url) | |
res_obj = lxml.etree.fromstring(bytes(res.text, encoding='utf8')) | |
lng = res_obj.xpath('//longitude/text()')[0] | |
lat = res_obj.xpath('//latitude/text()')[0] | |
return lng, lat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment