NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I want to find the old name of the city. So, using Nominatim API I just execute https://nominatim.openstreetmap.org/search?#?city=Kyiv&state=Kyiv&country=Ukraine&format=json&namedetails=1

And have a list of city's names.

But I can't figure out how to execute this query from the database.

I can write something like: SELECT name FROM placex WHERE OSM_ID='XXXXX'

But to do it I need to know the OSM_id of the city.

So, my question is How to find old names (or at least osm_id) of the city if I have city_name, state and country?

asked 18 Aug '20, 14:30

MariiaZav's gravatar image

MariiaZav
21223
accept rate: 0%


Searching for city use the API documented in https://nominatim.org/release-docs/latest/api/Search/

saint petersburg, russia

https://nominatim.openstreetmap.org/search.php?q=saint%20petersburg%2C%20russia&format=jsonv2

or structured, though many big cities are also states which makes it harder for a computer to differentiate

https://nominatim.openstreetmap.org/search.php?city=saint%20petersburg&country=russia&format=jsonv2

If you have your own server replace the domain the IP address of your server or 'localhost'.

Alternatively in your installation in the 'build' directory there's a script utils/query.php.

Add &namedetails=1 and you get a list of all names. https://nominatim.openstreetmap.org/search.php?q=saint%20petersburg%2C%20russia&format=jsonv2&namedetails=1&pretty=1

"name:tzl": "Sant Pairbuerg", "short_name": "СПб", "alt_name:mk": "Петроград", "alt_name:pl": "Sankt Petersburg", "alt_name:vi": "Sankt-Peterburg", "old_name:ar": "لينينغراد;بيتروغراد", "old_name:ca": "Petrograd;Leningrad",

permanent link

answered 18 Aug '20, 23:07

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Thank you for your answer. I have no problem to execute query from Nominatim API. The main problem is to run this query from the database. It has 784 tables and no descriptions of it.

I can't figure out how to get osm_id of the city without using Nominatim API and just using database.

(19 Aug '20, 19:01) MariiaZav

Adding &debug=1 to the URL https://nominatim.openstreetmap.org/search.php?city=saint%20petersburg&country=russia&format=jsonv2&debug=1 gives some output of the SQL that is run. In the background Nominatim uses several thousand lines of code to create and manage the SQL, finding places in a world-wide database is complex, especially finding the most relevant/important city when many have the same name. There's no single or few SQL queries one can run manually to get the same result.

(19 Aug '20, 20:49) mtmail

Thank you so much! I didn't know about the debug mode. It helps me a lot!

(20 Aug '20, 08:23) MariiaZav

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×710
×689
×147
×118
×10

question asked: 18 Aug '20, 14:30

question was seen: 3,379 times

last updated: 20 Aug '20, 08:23

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum