Getting parent of a geoname node

129 views
Skip to first unread message

Kelly Jones

unread,
Nov 28, 2008, 1:30:23 PM11/28/08
to geon...@googlegroups.com
If you visit:

http://ws.geonames.org/hierarchy?geonameId=4887398

it tells you Chicago (geonameid=4887398) is in Cook County
(geonameid=4888671) is in Illinois (geonameid=4896861) is in the
United States (geonameid=6252001) is in North America
(geonameid=6255149) is in the world/globe (geonameid=6295630).

Where can I download this parent/child information. It's not on the
download page?

--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.

Martin Sarsale

unread,
Nov 28, 2008, 4:22:16 PM11/28/08
to geon...@googlegroups.com
On Fri, Nov 28, 2008 at 7:21 PM, Martin Sarsale
<mar...@malditainternet.com> wrote:

> On Fri, Nov 28, 2008 at 4:30 PM, Kelly Jones
> <kelly.te...@gmail.com> wrote:
>>
>> If you visit:
>>
>> http://ws.geonames.org/hierarchy?geonameId=4887398
>>
>> it tells you Chicago (geonameid=4887398) is in Cook County
>> (geonameid=4888671) is in Illinois (geonameid=4896861) is in the
>> United States (geonameid=6252001) is in North America
>> (geonameid=6255149) is in the world/globe (geonameid=6295630).
>>
>> Where can I download this parent/child information. It's not on the
>> download page?
>
>
Kelly, from Marc suggestion, I preprocessed the geonames dump and
generated the hierarchy locally.
If you want to do the same, this is my recipe; not sure if it's
correct but it seems to work.

The first hierarchy is given by the feature_code:

So, you should start by looking nodes with feature_code = PCLI. That
place has a country_code, which will be the same for all the places in
the same country.
Then, you need to look for all the places with country_code you got
before, and feature_code=ADM1; this place will have an admin1_code
which will be the same in all places below this. Then, continue with
ADM2 and admin2_code, ADM3 and admin3_code, etc.

If you want, I can give you the source code to preprocess the dump.

:)


--
Martin Sarsale - mar...@malditainternet.com

Reply all
Reply to author
Forward
Message has been deleted
0 new messages