GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
How can i get parent of the feature like town-city-province-country?  XML
Forum Index -> FAQ - frequently asked questions
Author Message

Joined: 04/04/2008 19:05:08
Messages: 8

I know that if in the file "allCountries.txt" hierarchy exist.Like country code-Admin code1-Admin code 2-Admin3-Admin4..
But i dont understand what actually these codes provides.Mean if i take one feature any place name then can i get the parent of tht place using these codes?
Actualy i need hierarchy pf places.

like i ask one place forexample town then how can i get the city,province,state of selected place?I know about country that we can get the country of any feature.but question is if we can then how can we get city,province,state etc of selected feature.

Thanks so much for answer!

Joined: 11/02/2017 20:41:32
Messages: 10


I know this is an old post, but i have also been searching for a similar answer, so if i may add to this, and hopefully gain some knowledge

This is how my limited knowledge brain thinks it "should" work (i have done the same in the past but with areas of the UK only; And this works fine and fast):

- if each Feature in the allCountries had an additional column of ParentID (with exception to World (which has parentID of Self), unless you want Solar System, etc. too...).
This would make for very easy reference of what parent the feature belongs to; And would make selecting the direct Children of an area simple too.

I know i have limited knowledge of this type of data sets, so i am assuming i am missing the "better way" of doing this.
I would be very grateful if this "better way" could be pointed out and possibly explained with some sample SQL (preferably MySQL).

Thank you in advance

Joined: 11/02/2017 20:41:32
Messages: 10

anyone please?
is this forum/support active?

if i send payment for the premium option will this get me support?

Joined: 08/12/2005 07:39:47
Messages: 3927

Hi Jon

The admin hierarchy is encoded in the adminXcodes.

If you have a city (or other feature) then you look at the attributes: countrycode,admincode1,admincode2,admincode3 etc.
The combination of countrycode and admincode1 will give you the code of the corresponding adm1. You find the adm as the feature with the same countrycode and admincode1 and the featurecode 'ADM1'.
Similar to the lower admin levels.

Best Regards



Joined: 11/02/2017 20:41:32
Messages: 10

Thank you Marc

I will look at this over the weekend. i am making some progress

there is no admin3codes and admin4codes in the export section. this is what is confusing me a little too, as where do i then look for the these codes.

i dont suppose you could include some sample SQL as to how this would work for some sample areas.
i.e in both directions, get children of a country, then of state, city, etc and how to get the full parents for a city/town, etc with "en" place names, etc?
Forum Index -> FAQ - frequently asked questions
Go to:   
Powered by JForum 2.1.5 © JForum Team