Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am looking for a database that offers good accuracy for obtaining region from an IP address?

Or, if this question is too fuzzy: Which one is (possibly) the most accurate?

Note: I only need a database with IPs in Brazil, and only with region level accuracy. The location would be used to prefill a form on a web site. We also considered using web browsers' Geolocation API. However, as seen in a demo, in major browsers, the user would first have to opt in.

I already found freegeoip.net (demo) and MaxMind (demo). Of these two, only MaxMind correctly detects my current location: Las Palmas de Gran Canaria. freegeoip.net falsely reports: Madrid. However, MaxMind is rather pricey, which may be OK if we needed data for the whole world. But for Brazil only, price is questionable, and in addition, it is not even clear that their data for Brazil is good.

share|improve this question
add comment

2 Answers

I don't think your question is too fuzzy but instead I think your answers are going to be a bit too fuzzy. The internet is a screwed up place.

IP addresses are bought in blocks of thousands/millions at a time by big telecom companies, like AT&T or even Telefonica. They in turn sell those block off to smaller ISP at the local level. Then those ISPs can sell those off to whomever they like static or dynamic. So address you would expect to be in a certain place often are not. For example, according the LACINC and ARIN both report Brazil's Tourism Office's website is just outside New York City. But this could be just where their webserver is too.


For 'official' look-ups:

I know the ARIN has a service called RSW which has APIs for IP look-up that include locations. These locations only include a string with town name, and it province, nothing more accurate like a coordinate. While the ARIN is the North American council for the IANA it should be able to find local IPs in South America, though I don't know a local Brazil IP to test.

The LACNIC I think has a similar service but I wasn't finding it quickly.

Their look-ups can be fuzzy too: They report my IP to be Plano, Texas USA which is at least 400 miles away.


There is also this, though I have not used them personally, but they got my location spot-on:

https://www.geobytes.com/

They don't say how they generate their data, or where they buy it from. You could ask. They have a free service with a pop-up for revenue or you can purchase their service at what seems reasonable pricing.


Also being ignorant of your needs you could also, depending on how you are obtaining these IPs try Google Analytics. All you need is a small Javascript code inserted into your page and when a person visits your site Google records their location with some accuracy. You can then filter the data and export in a variety of formats that then your can use.

Also depending on how people are visiting your data collection site you could possible just ask them. If people are visiting your data collection point via a modern web browser you can put a little bit of code in the page and the browser will share that with you with the user's permission. It is really easy via HTML5, http://www.w3schools.com/html/html5_geolocation.asp I use a similar method on most of my web-mapping portals. But again I don't know how you are getting your information or this is an option. With GPS enabled mobile phones, this method is extremely accurate.

Final note, as more and more people use mobile devices expect weird results. For example my mobile phone reports its location as Saint Louis, Missouri USA though that is 300 miles away.

So I hope I helped a little and maybe can get you thinking about your problem and possible tools you can use.

share|improve this answer
    
Thanks for your detailed explanation and suggestions! See the edits that I made to my questions. –  feklee Jun 2 '13 at 16:15
    
To add: I think your requirement about finding only Brazil IPs is going to be... unobtainable. By definition the internet is a fuzzy place. IPs may give you a location but that doesn't not mean it will be the same place tomorrow in the next minute. Also IP addresses are a kind of commodity, a ISP may sell off a bunch of IPs to someone thousands of miles away. So you are going to have to look at everything at once to my best knowledge. –  RomaH Jun 2 '13 at 16:16
    
I would just need a database that provides IPs in Brazil. All other IPs would be classified as outside Brazil. Of course, regular updates are a must. –  feklee Jun 2 '13 at 16:18
1  
MaxMind got my location correct too. Unless you are going to build the database yourself I don't know of anyone who does a regional IP database because IPs can change so much. I was trying to illustrate that DBs like this would be impractical. –  RomaH Jun 2 '13 at 16:23
    
Perhaps there is some entity in Brazil registering all IPs and locations, I am hoping… Just tried the geobytes IP locator. They got my location wrong: Madrid –  feklee Jun 2 '13 at 16:28
show 2 more comments

I would suggest visiting ip-countryside on google coode ( https://code.google.com/p/ip-countryside/ ) and having a play with the code, there is also a link to download just the data. You would need to extract just the Brazil addresses but it should be a good starting point.

I haven't checked how accurate the info is but you should be able to get countries and cities.

here is some code courtesy of shawty.

#!/bin/bash
rm -f delegated-afrinic-latest
rm -f delegated-lacnic-latest
rm -f delegated-arin-latest
rm -f delegated-apnic-latest
rm -f delegated-ripencc-latest
rm -f ripe.db.inetnum
rm -f apnic.db.inetnum
rm -f ripe.db.inetnum.gz
rm -f apnic.db.inetnum.gz
wget ftp://ftp.afrinic.net/pub/stats/afrinic/delegated-afrinic-latest
wget ftp://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest
wget ftp://ftp.arin.net/pub/stats/arin/delegated-arin-latest
wget ftp://ftp.apnic.net/pub/stats/apnic/delegated-apnic-latest
wget ftp://ftp.ripe.net/ripe/stats/delegated-ripencc-latest
wget ftp://ftp.ripe.net/ripe/dbase/split/ripe.db.inetnum.gz
ftp -n -v ftp.apnic.net <<END
user anonymous anonymous@anonymous.org
binary
passive
get /apnic/whois-data/APNIC/split/apnic.db.inetnum.gz apnic.db.inetnum.gz
bye
END
gunzip ripe.db.inetnum
gunzip apnic.db.inetnum

The files are a bit of a pig to parse but will give you the info you need.

share|improve this answer
    
Thanks for the suggestion, but they say ip-to-country database. Also, the demo just shows the country I am located (Spain). Region information seems unavailable (cities I don't need). –  feklee Jun 2 '13 at 15:49
    
Format of lines in the database file is: ip_from ip_to country_code –  feklee Jun 2 '13 at 15:52
    
You are going to have to do a little bit more work and link the city information to something like geonames (geonames.org) or if you have a regional shapefile covering Brazil you could do a spatial join to fill in the gaps. Unfortunatly your ip only shows where you enter the internet which could be in a different region or in extreme circumstances a different country. This does however have the advantage of being free which might not be true of other solutions. –  Stevetech Jun 2 '13 at 19:24
    
I don't understand your recommendation. The ip-countryside database you mention in your answer only contains information about countries by IP. I, however, need regions in Brazil by IP. More accurate localization can be achieved by using the Geolocation API, but the user would have to opt in in most browsers. See also the latest updates to my question. –  feklee Jun 2 '13 at 22:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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