Till now, we used the free Geonames database as a location database to our project. But now, we want to implement area based search for our users, which isn't supported by Geonames, as each and every city, county, country etc. is marked geographically by a single latitude and longitude.

Is it possible somehow, to link the data from Geonames, to ways and relations (where available) from OSM?

We have a Nominatim server locally installed, and also have access locally to the Overpass api. I've searched for hours, but can't find anything that would help me in this matter:|

Basically, what I would like to do is either one of the following two:

  1. Keep the Geonames data about cities, counties, countries, etc. and link an OSM way, or relation id to them which marks their boundary, where available
  2. Leave out Geonames all together from the equation, and build a hierarchical location database with cities, counties, countries etc. from the OSM data (this would mean, a way to start from countries, and somehow list every other place that is hierarchicaly under the respective country, and store it in a database)

EDIT: I would prefer to go with the first option, if it is possible, but if it's not possible, I would be happy to get some guidance on how to achieve the second option, as the data is present hierarchicaly in the OSM data (it can be seen when searching with Nominatim), but I just can't find out how to obtain it easily.

asked 22 Feb '16, 16:31

Adam%20Baranyai's gravatar image

Adam Baranyai
61449
accept rate: 0%

edited 22 Feb '16, 20:03

aseerel4c26's gravatar image

aseerel4c26 ♦
32.0k16238549

As a clarification could you indicate what exactly you want to use from Geonames? Ancillary data, population etc?

(22 Feb '16, 22:25) SimonPoole ♦

Only the names of populated locations and administrative regions, together with their hierarchy. So, basically everything which has an fcode like PPL% or ADM%.

(22 Feb '16, 23:43) Adam Baranyai

From you comment I would be surprised if taking the 2nd route would not be superior given that you don't need any of the extra data GeoNames provides. Naturally the quality of OSM data varies by region, but in January I counted for GeoNames 8'712 vs. OSM 12'699 inhabited places in Switzerland .

It might be possible to extract the hierarchies from Nominatim but we will need somebody with the specific knowledge to way in.

permanent link

answered 23 Feb '16, 21:57

SimonPoole's gravatar image

SimonPoole ♦
38.3k13284608
accept rate: 19%

edited 23 Feb '16, 21:58

I was thinking about this problem, right now, I am experimenting with route 1, doing the following:

Fetching the needed records from the GeoNames database, reverse geocoding them by their latitude, longitude, with an ever decreasing zoom(starting from 15) until either I find an exact match to their name in the results, a very simmilar match to their name in the results or I reach zoom level 2. (of course, I am not looking for only exact matches, sometimes I delete some special phrases from the name, or add it, because there are some locations which are marked as "Something CP" in OSM data, and only "Something" in GeoNames, or vice-versa.)

As I've only installed Nominatim recently, I have only uploaded the data of Great Brittain, and I am experimenting with that. To process 100 such records from GeoNames in this way, it takes around 80 seconds(yes, it is rather slow, because to get the full information I need to reverse geocode, then geocode, then lookup the results, as I said, I am still experimenting, and trying to make this faster).

(24 Feb '16, 09:26) Adam Baranyai

As for the second route, I was thinking about something like the following: - show me each entity with admin level 3 from specific country - for each entity shown, show me each entity with admin level 4 - for each entity shown, show me each entity with admin level 5 - etc...

But this would still be incomplete, if for example, in a country, there is something that is a direct descendant which is not admin level 3, but 4,5,6...

(24 Feb '16, 09:28) Adam Baranyai

Some update on this situation: Since then, I've managed to fasten the script, by using the two php classes Nominatim uses, and leaving out the web-api from the calculation. This way, I can process 1000 records from GeoNames in ~92 seconds(almost 10x faster then the original version), and I get the following results for 1000 random rows: approximatly 607 records can be matched to an osm entity(node, way, relation), approximatly 100 records are tagged with an incorrect country_id in the geonames database (for example: some cities are tagged to be in GB, but when reverse-geocoding their lat-lon coordinates, it seems that they are in CY, additionally they're name also suggest that they are greek locations), and there are no name matches for the rest 293 records. With additional naming tweeks, I may obtain an even better result, but as for the time being, this seems okay to me(at least for GB, we will see how it fares on other regions of the world).

But if what you say is true, that OSM has better "coverage" regarding populated places around the world, it seems that the second route would be superior, and I should find a way to utilize that route.

(24 Feb '16, 14:50) Adam Baranyai
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:

×549
×350
×13

question asked: 22 Feb '16, 16:31

question was seen: 2,538 times

last updated: 24 Feb '16, 14:50

powered by OSQA