I need to get the coordinates of some accommodations automatically (and not by extracting them manually from, e.g., Google Maps) and then import them in QGIS. I've already seen that TripAdvisor has an API to download data, but a key is required and it doesn't seem easy to obtain one, especially for academic research.

Do you know if there are other providers that offer this service for free and without the need of a key, with the same quality of contents like TripAdvisor or Maps?

  • 1
    I can't vouch for quality, but have you tried openstreetmap.org ? – user1462 May 1 '16 at 20:06
  • Are you asking for a database of points of interest (POI)? Or about getting the locations of known addresses (i.e. geocoding)? – alphabetasoup Nov 10 '18 at 22:07

You could try using the Google Maps geocoding API (https://developers.google.com/maps/documentation/geocoding/intro). It works well, but there's a limit to 2,500 geocodes per user per day.

Here's a function to help geocode using Google. If you go over the daily query limit, or over the per second limit of 10 per second you'll get an error message instead of a tuple with XY coordinates. You can use time.sleep() to space out the queries to avoid this error.

import urllib
import httplib
import json
def Googlegeocode(address):
    base = '/maps/api/geocode/json'
    path = '{}?address={}&sensor=false'.format(base, urllib.quote_plus(address))
    connection = httplib.HTTPConnection('maps.google.com')
    connection.request('GET', path)
    rawreply = connection.getresponse().read()
    reply = json.loads(rawreply.decode('utf-8'))
        return(reply['results'][0]['geometry']['location']['lng'], reply['results'][0]['geometry']['location']['lat'])
        for k, v in reply.iteritems():
            return k, v

Also, Google offers a free API key for you to use; the function doesn't use one but if you use a module like pygeocoder (https://pypi.python.org/pypi/pygeocoder) you'll have to obtain an API key to use with it.

You can also check out the geocoder python module (https://pypi.python.org/pypi/geocoder); it provides access to multiple geocoding services including Open Street Map.

| improve this answer | |
  • I suspect OP is really asking about a POI database, and not geocoding known addresses, but it's unclear. – alphabetasoup Nov 10 '18 at 22:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.