Jonathan Marin
Jonathan Marin

Reputation: 57

Using longitude and latitude in GeoIP to get geographical information

I have been using GeoLite2 from the GeoIP package in Python to geolocate IP-adresses. It is quite easy. Using this code i.e. i can obtain a lot of information about the IP-address:

reader = geolite2.reader()
reader.get('131.165.115.153') 

Which produces the following output (a snippet of the output) from which i can obtain a postal code as well as geolocation:

location': {'accuracy_radius': 50,
'latitude': 56.3843,
'longitude': 10.503,
'time_zone': 'Europe/Copenhagen'},
'postal': {'code': '8550'},

Is there a way to look up this information based not on IP-address, but based on longitude and latitude? I have a list of lon and lat coordinates and i want to know the postal code of each location. Since both lon and lat as well as postal codes are in the GeoIP database, i suppose there would be a way to look up information based not on IP but lon and lat.

I have looked through the documentation for GeoIP, but i cannot find any obvious way to achieve this.

Upvotes: 2

Views: 1100

Answers (0)

Related Questions