Krulg
Krulg

Reputation: 55

How to get country/city from latitude and longitude offline?

I need to get a country and the closest city from longitude and latitude while being offline using python 3. I've tried module reverse_geocode here but it only works with python 2. Any suggestions would be appreciated.

Upvotes: 1

Views: 4092

Answers (2)

Bthompso8784
Bthompso8784

Reputation: 21

Six days after you posted your question, the reverse_geocode module was updated to support Python 3.

Upvotes: 2

SteveJ
SteveJ

Reputation: 3323

The code is not the problem -- a lookup by lat/lon is trivial. The problem is finding a lookup table that is maintained. The relationship between the two are not possible with an algorithm - so a lookup table must be created (and equally important), maintained.

This is a lot of work, and it isn't work that is fun or interesting. Finding an open source (and free) project of volunteers wanting to do this work is unlikely. Even if you do, it is unlikely that it will be kept as current as you like.

This is one of those times were paying for something is probably your best bet. In which case, just do a google search on a list of lat/lon vs city, or something of the sort. I quickly found this one that you could pay for and download regular updates, greatdata.

Once you get your list, you can solve many of your problems by putting it in a database that supports geo-location features (many do, MongoDB, for example). Then you can run queries such as (find everything within a 10-mile radius of lat/lon.)

Upvotes: 2

Related Questions