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

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 '20, 14:54

qeepcologne's gravatar image

qeepcologne
11112
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 '20, 19:31

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

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 '20, 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:

×689
×107
×85
×8

question asked: 30 Oct '20, 14:54

question was seen: 2,593 times

last updated: 16 Nov '20, 09:45

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