There are several ways to get this information:
A list of allocated or assigned IP addresses and AS number is published by each RIR, and they provide mirrors for each other's data. Take a look at ftp://ftp.ripe.net/pub/stats/. Look for the delegated-* files. They contain lines like:
ripencc|NL|ipv4|37.77.56.0|2048|20120201|allocated
ripencc|NL|ipv6|2a00:8640::|32|20120130|allocated
The country codes listed here are very rough indications of where an address is going to be used. Geolocation companies might use this as a basis, but they have much more accurate data from cooperation with big web stores etc.
PS: the RIRs are not companies, they are membership organisations. Everybody who needs IP addresses can become a member, get voting rights at the AGM, etc. Their policies are determined by an even wider community where everyone can participate (see http://www.ripe.net/ripe/policies).