Overpass: How to find the most IMPORTANT feature near a given point?

Hello,

I recently took some photos on vacation. They are geotagged, and I can retrieve the coordinates from the image file easily with exiftool.
I thought it would be a fun project to try to use OSM data to give the photos a better name… Rather than "IMG_20240929133700.jpg" I’m hoping for something like "Germany/Cologne/Cologne Cathedral_20240929133700.jpg", or the equivalent in the local language, "Deutschland/Köln/Kölner Dom_20240929133700.jpg" if the translation is too difficult.

My initial attempt was using nominatim which was fun but not really a complete solution. For example, when I query for 50.94060085,6.95623888 I get a result of "7, Wallrafplatz, Andreasviertel, Altstadt-Nord, Innenstadt, Köln, Nordrhein-Westfalen, 50667, Deutschland". This is technically correct for those coordinates, but of course the coordinates are slightly off from reality – the photo was actually of the nearby Cathedral. However, I noticed that the JSON data included an interesting field "importance":0.21912463163390336, which gives a rough estimate of how likely it is that this is the place someone is actually searching for. So I searched for a way to incorporate “importance” into my nominatim search and could not find a way.

My next attempt was with overpass, where I discovered that I could query nearby objects with something like nwr[importance](around:300, 50.94060085,6.95623888). I think this is close to what I seek – the way for Kölner Dom is within 300 meters of my coordinates and has the tag"importance": "international". It’s not clear to me why this one has a descriptive word where nominatim has a numerical value… The number would be much easier to rank. But more importantly, it seems to be just luck that Kölner Dom has this tag at all – no other object within the radius has an “importance” tag. When I attempt a similar strategy with coordinates from the nearby Rheinpark – 50.9492556,6.9727594 – I find no objects with the “importance” tag at all.

I’ve been using the overpy python package to do these queries, if it makes a difference.

Is there a way to access a numerical “importance” tag with Overpass, like I get with nominatim?
Ideally, I’d like to return only the most important object within my search radius, or perhaps a ranked set of the top five, or something similar.

Thanks for your help, and thanks for making this data publicly available in the first place!

No, there is no such ‘importance’ tag in OSM at all. Having said this, where should ‘nominatim’ get this from or why do you think that ‘nominatim’ has such a feature?

Edit: provide link to nominatim’s ‘importance

Welcome!

Nominatim calculates the importance of a place based on how many people visit the Wikipedia article about the place. It uses this to rank search results so that, for example, New York, US, ranks higher in search results than New York, England. For more information, see the Nominatim documentation.

The results you are getting from Overpass are objects that have the importance= tag in OSM. This tag does exist, but it is mostly used on railway infrastructure (more info). It will not serve your needs.

What you’re after seems closer to what Nominatim does, so I would use the Nominatim documentation as a starting point. It looks like you can download files (preprocessed importance tables) there, so you could e.g. try checking for the most important feature within a certain radius. (I don’t know how complete these tables are, and if they even include all feature types that Nominatim indexes.)

2 Likes

Thanks very much for your replies, that was very helpful. I will take a crack at this wikimedia-importance.sql.gz file.

Just out of curiosity, can you think of any way to arrive at a similar answer purely with Overpass? Just looking at the map, I wonder if there would be a way to simulate “importance” by gauging at which zoom level labels appear. For instance, to stick with the “Rheinpark” example:
the “Rheinpark” label appears at zoom level 15
“Rosengarten” appears at 16
“Igelbrunnen” appears at 17
“Rheinpark” DISappears at 18…

Just want to point out that we’ve recently released an update of Nominatim’s importances which now comes in a more handy CSV format: https://nominatim.org/data/wikimedia-importance.csv.gz

The general idea behind the importance is: prefer OSM objects with a wikipedia and/or wikidata tag. If it has a Wikipedia article, it must be somewhat notable. Nominatim’s importance file just adds a relative ranking between the different article. You might not even need that in a first approach.

On top of that a personal ranking by tag might be useful. You are more likely to take a picture of, say, an amenity=fountain than of a amenity=waste_disposal.

4 Likes

Thanks! This file is very helpful.

All of the nominatim data have a linked wikidata tag, so I’m going to try to link this with the data from my Overpass query.

My humble suggestion: import the “importance” data into the Overpass dataset, perhaps as a "nominatim:importance" tag. It’s useful, and the data is already freely available, and easy to link to the respective objects.