Is it posible to extract data from OpenStreetMap that only contains the name of a city and the name of the state from these city?

I want to build a CSV file, where each row contains "city;state". For example:

San Francisco;California

At the moment I'm using osmfilter and osmconvert to create a file from all cities.

osmfilter file.o5m --keep="place=city or ( place=town and population>=1000 )" --drop-relations --drop-ways > cities.osm
osmconvert cities.osm --all-to-nodes --csv="name" --csv-headline > cities.csv

But how can I add the information about the state / country?

  • have you considered geonames.org instead – Ian Turton Jun 6 '18 at 10:20
  • yes, but I want to receive the data from openstreetmap because I want to extend my file with other names later. For example: If the city is on an island, I want to add the name from the island in the third column. – 501 - not implemented Jun 6 '18 at 10:28
  • Have you considered to use the famous overpass-api (or overpass-turbo.eu) for that query? Maybe you can try a query for each of the 50 states in the USA (via a batch, or a recursive command) where you extract objects with place=city or ( place=town and population>=1000) – stephan75 Jun 6 '18 at 20:50
  • Overpass looks nice. Is there a way to build the query that returns a specific language for the states name? – 501 - not implemented Jun 7 '18 at 7:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.