Skip to content

Instantly share code, notes, and snippets.

@lightondust
Created November 13, 2020 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lightondust/734f74be00cc79a152613d5c8b66eab7 to your computer and use it in GitHub Desktop.
Save lightondust/734f74be00cc79a152613d5c8b66eab7 to your computer and use it in GitHub Desktop.
get coordinate from address
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