drolbr / Overpass-API

A database engine to query the OpenStreetMap data.
http://overpass-api.de
GNU Affero General Public License v3.0
690 stars 90 forks source link

Overpass vs. Nominatim - different results #714

Open dlubom opened 5 months ago

dlubom commented 5 months ago

Hello,

I’ve noticed that when I use this Overpass query (here’s the link: overpass turbo), which relates to tags for the country of Oman, it seems to return a complete list of tags.

[out:json]; relation(305138); out tags;

However, when I perform a similar query on Nominatim, I get many more tags.

Nominatim Demo

For instance, it appears to be missing what seems like a key tag, “official_name:en” which is present on Nominatim but not on Overpass.

ImreSamu commented 5 months ago

For instance, it appears to be missing what seems like a key tag, “official_name:en” which is present on Nominatim but not on Overpass.

The OSM API indicates that the relation with ID 305138 seems to lack the official_name:en key;

...   timestamp="2023-08-12T12:37:12Z"  ...
...
<tag k="name:zh-Hans" v="阿曼"/>
<tag k="name:zh-Hant" v="阿曼"/>
<tag k="official_name" v="سلطنة عمان"/>
<tag k="official_name:ar" v="سلطنة عمان"/>
<tag k="official_name:ckb" v="سەڵتەنەتی عومان"/>
<tag k="official_name:cs" v="Sultanát Omán"/>
<tag k="official_name:eo" v="Omana Sultanlando"/>
<tag k="official_name:pl" v="Sułtanat Omanu"/>
<tag k="ref" v="OM"/>
<tag k="state_code" v="OM"/>
<tag k="timezone" v="Asia/Muscat"/>
<tag k="type" v="boundary"/>
<tag k="wikidata" v="Q842"/>
<tag k="wikipedia" v="ar:سلطنة عمان"/>
...

EDIT:

As I see it, Nominatim might have automatically added the missing OSM tags from 'Linked Places'.

image

<node id="424315291" visible="true" version="80" changeset="135337586" timestamp="2023-04-25T10:46:35Z" 
...
<tag k="official_name" v="سلطنة عمان"/>
<tag k="official_name:ar" v="سلطنة عمان"/>
<tag k="official_name:be" v="Султанат Аман"/>
<tag k="official_name:br" v="Sultanad Oman"/>
<tag k="official_name:ca" v="Sultanat d'Oman"/>
<tag k="official_name:ckb" v="سەڵتەنەتی عومان"/>
<tag k="official_name:cy" v="Swltaniaeth Oman"/>
<tag k="official_name:de" v="Sultanat Oman"/>
<tag k="official_name:el" v="Σουλτανάτο του Ομάν"/>
<tag k="official_name:en" v="Sultanate of Oman"/>
<tag k="official_name:eo" v="Omana Sultanlando"/>
<tag k="official_name:et" v="Omaani Sultaniriik"/>
<tag k="official_name:eu" v="Omango Sultanerria"/>
<tag k="official_name:fr" v="Sultanat d'Oman"/>
<tag k="official_name:id" v="Kesultanan Oman"/>
<tag k="official_name:it" v="Sultanato dell'Oman"/>
<tag k="official_name:lb" v="Saltanat Uman"/>
<tag k="official_name:lt" v="Omano Sultonatas"/>
<tag k="official_name:pl" v="Sułtanat Omanu"/>
<tag k="official_name:pt" v="Sultanato do Omã"/>
<tag k="official_name:ro" v="Sultanatul Oman"/>
<tag k="official_name:ru" v="Султанат Оман"/>
<tag k="official_name:sr" v="Султанат Оман"/>
lonvia commented 5 months ago

Yes, Nominatim tries to link up administrative boundaries to an appropriate place node and then mixes in the name tags from the place into the response. The linking is somewhat involved. If you want to do it in Overpass, the best strategy is to look for a node with a place tag and the same wikidata tag. No idea if that is possible with OverpassQL. You can also use Nominatim's lookup endpoint to retrieve the extended information given an OSM relation ID. Use namedetails=1.

mmd-osm commented 5 months ago

If you want to do it in Overpass, the best strategy is to look for a node with a place tag and the same wikidata tag. No idea if that is possible with OverpassQL

If you're lucky and the place node is a relation member, the query is pretty fast:

(
  relation(305138);
  node(r)[place][wikidata](if:t["wikidata"] == u(t["wikidata"]));
);
out;

Checking all place/wikidata nodes is much slower:

(
  relation(305138);
  node[place][wikidata](if:t["wikidata"] == u(t["wikidata"]));
);
out;

Since Overpass returns the original OSM objects, you need to merge relation / node tags locally in a post-processing step.