I am looking for offline geocoder that would

  • locate country where specific point is located
  • be usable in a Ruby script
  • work offline (required due to a high number of points)
  • is using OpenStreetMap data or other on a compatible license
  • accurate, objects hundreds meters from country border should be also correctly located

I am fine with some setup. Limited performance is also OK, number of processed entries is not massive and I am fine with script running for week or two.

Note that I am fully aware about number of geocoding APIs, I am currently using one but I need something that works offline.

1 Answer 1


I'm not a big Ruby user, but it took me about ten seconds of Googling to find this. It appears to have:

  • Point-to-country using latitude and longitude from a variety of sources - simply a single function call
  • Uses GeoNames open-source data
  • Is accurate in most places, but since it works by finding known places nearest to the chosen point. I did test it about 150m from the Austria-Switzerland border, and it worked in 3 separate locations (but failed on the fourth). Past about 350m from any border, it should work well.
  • See github.com/sildur/offline_geocoder/issues/11 - not sure is it a bug or not, but by looking at results and design it fails "accurate" part. It is not actually using any border data, it just finds nearest big city and gives its country as a result. Still, if no better answer will appear I will award bounty to you. Jun 14, 2019 at 21:54
  • @MateuszKonieczny My interpretation of the Medium article is that calculating the city is just to get the information it returns to you: i.e, precise to the nearest city. However, to judge that, it uses 14 million landmarks, and finds the nearest one to your location and finds what country/city that is in. Therefore, while it's not precise, I think (I'm not sure, though) it is accurate, at least to the country scale. Jun 14, 2019 at 21:59
  • To clarify - I was using it already and it is exactly what prompted "accurate" section and linked issues - this geocoder declared parts of USA to be within Canada. Jun 14, 2019 at 22:01
  • Ah right, sorry, I didn't understand that. Jun 14, 2019 at 22:02
  • I awarded bounty - there was no better answer, and while it is not solving my problem I probably should list what I tried. Maybe it will be useful for others. In case a new answer actually solving my problem I would be happy to make a next bounty and award it. Jun 19, 2019 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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