GeoNames is a series of web services to an extensive geographical database of over 8,000,000 names. The database is also available for “bulk” download. Both access methods are under the Creative Commons attribution license. The web services are available through free and commercial interfaces, and using a number of different format/protocols.
The core GeoNames database contains over 8,000,000 geographical names representing over 6,500,000 unique features. Each feature has various information stored about it, including a location (geographic WGS84 coords), elevation, name in various languages, population, administrative sub-division(s), one of nine feature classes, and one of 645 feature codes.
The data is primarily taken from a range of official public sources, and the quality and completeness of these sources can be variable. However, there is also a “wiki” interface, allowing users to manually edit and improve the database. Registered users can add new features, edit them, move them, etc.
The databases are available under the Creative Commons attribution license as a bulk download, or through a series of web services. The full list of web services are listed on the GeoNames.org website, here. These are RESTful, and most support XML or JSON responses. RDF, CSV, TXT, RSS, or KML responses are also available for a small subset of the services. There are currently 32 different services covering tasks such as: find nearby, post codes, earthquakes, nearby Wikipedia articles, children (ie. component areas – eg. countries in a continent), timezones, ASTER/SRTM elevation, and weather station reports.
The web services can be used through a free interface, or through a commercial interface. The commercial interface requires the pre-purchase of “credits”. The commercial interface provides a better service with better availability and higher usage caps. Two commercial interfaces are provided, depending on if availability or cost is most important. Both systems revert to the free service if credits are exhausted.
Geonames provide a number of their own APIs, and a number of third party APIs are also available. Any language that supports HTTP requests could be used, but languages and environments with specific libraries available, include: Java, Drupal, Perl, Lisp, Ruby, PHP, Django, .NET WCF, and Python.
A popular PHP library is the Services_Geonames package available from PEAR (Services_Geonames download). It uses the JSON interface, but parses the responses into a PHP associated array. Most of the searches (e.g. the search for all places called “Washington”) can be further constrained. This is useful as many place names can refer to dozens of places.
A semantic web interface is also available, although the documents describing this have not been updated for a couple of years. Each GeoNames feature has a unique URI. This can lead to either the corresponding HTML wiki page, or an RDF description of the feature using elements of the GeoNames ontology. Applications for the semantic web interface are probably limited at the moment, although there is probably scope in trying to combine the data with LinkedGeoData.org.
GeoNames is a popular web service, and is already being used a range of online map applications including iPhone applications. Unlike many fully-commercial geocoding/reverse-geocoding systems, it has a wide international coverage including multi-lingual capabilities. With 32 different services, it has a wide range of capabilities beyond basic geocoding, with support for elevation, earthquakes, weather, and Wikipedia articles. Have a look at GeoNames, next time you need a geocoding solution.