i am trying to lookup localized city name from gps position via nominatim reverse call, which works pretty well when user is in town. But when in the middle of nowhere (e.g. user is anchored with his yacht near the coast), nominatim return only the administrative region. example: https://nominatim.openstreetmap.org/reverse?format=jsonv2&lat=36.540548&lon=35.742612&zoom=18 the same is returned without reverse: https://nominatim.openstreetmap.org/search?format=jsonv2&q=36.540548,35.742612&zoom=18 What we need is the name of the nearest town. Any suggestions, experiences or hacks (e.g. town of next atm or something) to get that?

asked 30 Oct, 14:54

qeepcologne's gravatar image

qeepcologne
112
accept rate: 0%


Nominatim, being a reverse geocoder aiming to give you the address for your location, is the wrong tool for this job.

Overpass is a slightly better tool; it cannot (to my knowledge) give you the "closest" of something but it can give you "nearby things" in a given radius - here, all cities and towns within 50km of the given position:

node(around:50000,53.6509,6.8310)[place~"^(city|town)$"];
out geom;

The task of identifying the closest of several results would still be yours to solve, and this solution would, unlike Nominatim, not tell you the administrative hierarchy (i.e. what county/state/country the city is in).

The best solution would probably be a server that you run yourself, with OSM data imported into a PostGIS database and a small script that would run a nearest-neighbour search in the database and return only the closest place. This would have the added advantage of not relying on servers run by other people.

permanent link

answered 30 Oct, 19:31

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
74.9k876751157
accept rate: 24%

thanks a lot, i tried with your query on overpass-turbo and results are looking ok. We run nominatim (via docker image) on our own server. I used the openstreemap.org url to demonstrate the query to work for everybody, because our server is not public. So i have to find out how to run/install nominatim and overpass on the same database via docker.

(16 Nov, 08:46) qeepcologne
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:

×619
×92
×76
×7

question asked: 30 Oct, 14:54

question was seen: 127 times

last updated: 16 Nov, 09:45

powered by OSQA