Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of all city/place names in a country using Nominatim/OpenStreetMap

I have set my own OpenStreetMap server (database is PostGis) and I'm using Nominatim for geo-coding and conversions from address to coordinate or coordinates to addresses. I need to get a list of all place names (cities, towns, villages etc.) from a country, but I still have trouble with understanding the DB structure. Any ideas how to do that?

I know there are other solutions (GeoNames or other available databases), please understand that I do not want to use them and I need to do this just by using OSM database and/or Nominatim database.

like image 893
andrei Avatar asked Feb 03 '26 15:02

andrei


1 Answers

You need to download the OSM data you are interested in and load it to PostGIS using osm2pgsql. (not sure if you have already done this)

Then you just run the query:

  select name from planet_osm_point where place in ('city','town','village');

The data is not guaranteed to be complete off course, because the labelling is done in a crowd-sourced way.

like image 122
grasshopper Avatar answered Feb 05 '26 03:02

grasshopper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!