Reputation: 831
I'm getting wrong location when I query the GeoLite2-City.mmdb database with ip = '104.6.30.56' (from Python). Their demo site returns good data for this IP (https://www.maxmind.com/en/geoip-demo).
In [33]: import geoip2.database
In [34]: reader = geoip2.database.Reader('.../GeoLite2-City.mmdb')
In [35]: reader.city('104.6.30.56').city # should be Santa Rosa, Ca
Out[35]: geoip2.records.City(geoname_id=None, confidence=None, _locales=['en'], names={})
In [36]: reader.city('104.6.30.56').location # should be ~(38, -122)
Out[36]: geoip2.records.Location(postal_confidence=None, average_income=None, accuracy_radius=None, time_zone=None, longitude=-97.0, metro_code=None, population_density=None, postal_code=None, latitude=38.0)
In [37]: reader.city('173.194.116.131').city # works fine for Google
Out[37]: geoip2.records.City(geoname_id=5375480, confidence=None, _locales=['en'], names={u'ru': u'\u041c\u0430\u0443\u043d\u0442\u0438\u043d-\u0412\u044c\u044e', u'fr': u'Mountain View', u'en': u'Mountain View', u'de': u'Mountain View', u'zh-CN': u'\u8292\u5ef7\u7ef4\u5c24', u'ja': u'\u30de\u30a6\u30f3\u30c6\u30f3\u30d3\u30e5\u30fc'})
Versions:
In [39]: reader.metadata()
Out[39]: maxminddb.reader.Metadata(binary_format_major_version=2, description={u'en': u'GeoLite2 City database'}, record_size=28, database_type=u'GeoLite2-City', languages=[u'de', u'en', u'es', u'fr', u'ja', u'pt-BR', u'ru', u'zh-CN'], build_epoch=1438796457, ip_version=6, node_count=3199926, binary_format_minor_version=0)
In [40]: geoip2.__version__
Out[40]: '2.2.0'
Is this because I'm using Lite version?
Upvotes: 0
Views: 1790
Reputation: 1161
If GeoIP returns the correct result and GeoLite does not, then yes, you're likely seeing the impact of the degraded accuracy of GeoLite. It's really a question of "do you want to pay, and if so, how much?"
Bear in mind that they recently introduced a third-level "Precision" service offering, of which the City database is itself now a degraded version.
Upvotes: 0
Reputation: 150198
Geoip location is only somewhat accurate.
Providers like MaxMind do their best to understand what IP address is associated with what geo location. However, that is a daunting task. IP addresses can be reassigned by the company that controls them, some companies do not publish the geography associated with an address, the IP you observe might belong to a proxy server far from the actual user, and there can be errors compiling the data.
Since their online system returns the correct geo location, this is probably an example of that final category.
In working extensively with geo location and correlating it to known facts about users, I observe that geo location databases are accurate around 85% - 90% of the time. Some providers do more than others to correctly handle the harder-to-handle IP addresses, but none of them are perfect.
Upvotes: 0