Quantcast
Channel: Planet Python
Viewing all articles
Browse latest Browse all 24353

Catalin George Festila: Python 2.7 : Python geocoding without key.

$
0
0
Today I will come with a simple example about geocoding.
I used json and requests python modules and python version 2.7.
About geocoding I use this service provide by datasciencetoolkit.
You can use this service free and you don't need to register to get a key.
Let's see the python script:
import requests
import json

url = u'http://www.datasciencetoolkit.org/maps/api/geocode/json'
par = {
u'sensor': False,
u'address': u'London'
}

my = requests.get(
url,
par
)
json_out = json.loads(my.text)

if json_out['status'] == 'OK':
print([r['geometry']['location'] for r in json_out['results']])
I run this script and I test with google map to see if this works well.
This is output and working well with the geocoding service:

Viewing all articles
Browse latest Browse all 24353

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>