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:https://nominatim.openstreetmap.org/reverse

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
11235
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 ♦
66.7k806151033
accept rate: 24%

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 https://nominatim.openstreetmap.org/reverse.php?format=html&lat=35.62534009803395&lon=-95.48938751220705&zoom=12

permanent link

answered 30 May '18, 10:47

mtmail's gravatar image

mtmail
2.1k437
accept rate: 24%

Your answer
toggle preview

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:

×107

question asked: 30 May '18, 08:25

question was seen: 244 times

last updated: 30 May '18, 10:47

powered by OSQA