Here you can download the pre-generated data with over 21 million place names for the whole planet. Feel free to use it in your next project, your website, your company product, or just for your private research.
The file is available under the Open Database License, the same license as the original OpenStreetMap data.
It is pretty easy to filter the records for a country of your choice from the downloaded planet dump. Use a command like:
$ zcat planet-latest.tsv.gz | awk -F '\t' -v OFS='\t' 'NR == 1 || $16 == "ch"' > switzerland.tsv
Where “ch” is the 2 letter country code according to ISO-3166, in this case for Switzerland. Similarly, it is possible to extract only records of certain types or classes and set a filter on another column.
Because the data contains lon/lat columns as well as bounding boxes (west, south, east, north), you can also extract all records by geographical filters.
To create an extract of all place names in the area of Zurich in Switzerland you can run a command like:
zcat planet-latest.tsv.gz | awk -F '\t' -v OFS='\t' 'NR == 1 || ($8 > 47.225 && $8 < 47.533 && $7 > 8.275 && $7 < 8.800)' > zurich_switzerland.tsv
To find the relevant bounds check the Bounding box tool or list with city and country boundaries.
The data is generated in the TSV format, a tab-separated spreadsheet file with one record per row. The first row contains the name of the columns. All characters are UTF-8 encoded. The files distributed with a release are compressed using gzip. We suggest using gzip or zcat to extract the raw text.
The columns have a fixed order:
name the name of the feature (default language is en, others available(de,es,fr,ru,zh))
alternative_names all other available and distinct names separated by commas
osm_type the osm type of this feature (node, way, relation)
osm_id
class
type
lon
lat
place_rank rank from 1-30 ascending depending on the type and class
importance importance [0.0-1.0] depending on wikipedia if available otherwise just the ranking
street
city
county
state
country
country_code ISO-3166 2 letter country code
display_name the display name representing the hierarchy
west bbox
south bbox
east bbox
north bbox
wikidata the wikidata associated with this feature
wikipedia the wikipedia URL associated with this feature
The open-source code for generating the data is available in the repository https://github.com/osmnames/osmnames
The Place Search API used on this website is implemented with the open-source project available at https://github.com/klokantech/osmnames-sphinxsearch.
Do you need geocoding API or Maps API with SLA and commercial support? Try maps for developers by MapTiler.
OSMNames project is maintained by the OSM community, Geometa Lab HSR, and MapTiler.