GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Geonames tree, parent/child relationship, problem with Athens/Greece  XML
Forum Index -> General
Author Message
donald128



Joined: 29/04/2009 17:38:01
Messages: 6
Offline

Hey!

I use geonames DB locally.
For our program a world location tree is required.
To build a tree you need to find parent/child relationships in geonames DB.

To find parent of a city (Paris) I do the following.
1. find Paris id in geonames table: 2988507
2. take country_code: FR
3. take admin1_code: A8
4. take admin2_code: 75
5. compose a key from the codes "FR.A8.75"
6. The key enables me to find admin2 code in admin2Codes.txt table: 2968815 (D├йpartement de Ville-de-Paris)
The parent is 2968815
Nice!

Do I look for parent in a right way?
Pleas point me to a right direction if I'm wrong.

Unfortunately this algorithm does not work for some countries.
Greece is one of them.
When I look for parent for Athenes/Greece (264371) the following problem arises.
2. take country_code: GR
3. take admin1_code: [empty]
4. take admin2_code: 35
5. key: "GR..35"

There is no this key in admin2Codes.txt table
However there is this key
GR.ESYE31.35

Why ESYE31 missing for Athens in admin1_code in geonames table?
Is it error in the database or the DB is correct and I'm using it in a wrong way?


Thank you for the project!

Pavel Repkin
david masclet



Joined: 26/11/2007 11:49:58
Messages: 67
Offline

Hi

When i have coded Gisgraphy i got the same question, i have coded an algorithm that try to detect adm by codes and try to correct (potential) errors.

You can see the code here or use the gisgraphy importer that inject geonames csv files into a postgres database in a tree structure

Hope it helps
David
[WWW]
marc



Joined: 08/12/2005 07:39:47
Messages: 4501
Offline

I have added the missing adm1 codes for Greece, deriving them from the admin2 code. Do not use the algorithm David is suggesting if you don't want to have a lot of errors.

Marc

[WWW]
david masclet



Joined: 26/11/2007 11:49:58
Messages: 67
Offline

Hi

Marc is right, the algorithm is not sure.

I should have precise that the algorithm is based on some suppositions that are not always true. it is not determinist. The goal is tu run the algo and to manually check if the result is correct. it can save times but can loose too in an other way if the suppositions are not true.

i have check and the algo can't correct the error in this case.

David
[WWW]
donald128



Joined: 29/04/2009 17:38:01
Messages: 6
Offline

Thank you Marc and David.
It works now - I can find admin1 for Athens and all other Greek locations!

 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team