Good afternoon!

Does the OSM have an API method for obtaining the nearest settlement to the specified coordinates?

The method for reverse geocoding returns only the exact address of the object with the given coordinates:

The problem arises when the given coordinates do not have a specific locality, but the region is very large.

Thank you in advance.

asked 30 May '18, 08:25

Helen%20Kir's gravatar image

Helen Kir
accept rate: 0%

The focus of OSM is providing data - not so much providing data access APIs. It is possible that you could do something with Overpass that gets you halfway there, but if you need to make these kinds of queries often, it would be a good idea to

  • download the full "planet file" with all OSM data,
  • import it into a PostGIS database using e.g. osm2pgsql with a modified "style file" that essentially tells osm2pgsql you're only interested in place names or settlements (alternatively: use osmium-tool to filter the planet file for place names or settlements, then use plain osm2pgsql to import the resulting file)
  • use a PostGIS query to find the nearest place to a given pair of coordinates

Since you're only interested in a fraction of OSM data, you shouldn't need too much disk space or memory for this, and you'll be able to make fast queries.

permanent link

answered 30 May '18, 10:10

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

With Nominatim you can try the &zoom parameter. Default is trying to find an exact address (house number) 18. With 2 it looks just for the country. You can see the possible values in the dropdown field on

permanent link

answered 30 May '18, 10:47

mtmail's gravatar image

accept rate: 29%

Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 30 May '18, 08:25

question was seen: 1,067 times

last updated: 30 May '18, 10:47

powered by OSQA