Geonames.org search results

6 views
Skip to first unread message

Alexandre Passant

unread,
Jan 5, 2007, 11:40:09 AM1/5/07
to ge...@googlegroups.com
Hi all,

I've just discovered geopy while trying to fetch geonames.org services
results with Python.

Yet, I realized that the API only looks for the "postalCodeSearch"
service of geonames.org [1] and there is no way to use the basic
search service [2], which sometimes gives better results, eg [3] vs
[4] (especially if getting the 1st result) + [5] vs [6].

I hacked the lib so that we can pass a resource option to the
geocoders.GeoNames() method.
resource='search' will search the basic service [2], while the default
option (to be coherent with the current API) is to use the
"postalCodeSearch" service.

Patch is available at [7], as well as the rewritten geocoders.py
(based on current SVN version).

Of course, feel free to add it in the API itself or re-code it if you
want, I think it's worth getting it.

Cheers,

Alex.

[1] http://www.geonames.org/export/
[2] http://www.geonames.org/export/geonames-search.html
[3] http://ws.geonames.org/search?q=zurich%20Suisse
[4] http://ws.geonames.org/postalCodeSearch?placename=Zurich%20Suisse
[5] http://ws.geonames.org/postalCodeSearch?q=Cork%20Ireland
[6] http://ws.geonames.org/search?q=Cork%20Ireland
[7] http://apassant.net/home/2007/01/geopy-geonames

Brian Beck

unread,
Jan 5, 2007, 1:12:50 PM1/5/07
to geopy
Alexandre Passant wrote:
> I hacked the lib so that we can pass a resource option to the
> geocoders.GeoNames() method.
> resource='search' will search the basic service [2], while the default
> option (to be coherent with the current API) is to use the
> "postalCodeSearch" service.

> Patch is available at [7], as well as the rewritten geocoders.py
> (based on current SVN version).

Good idea, GeoNames support definitely needed some love. Thanks for
the patch!

--
Brian Beck
Adventurer of the First Order

Alexandre Passant

unread,
Mar 11, 2007, 8:49:37 AM3/11/07
to ge...@googlegroups.com
Hi,

A little update to the previous patch, so that it now adds geonameId
to results if using the 'search' method

Still available at http://apassant.net/home/2007/01/geopy-geonames

Best,

Alex.

Alexandre Passant

unread,
Jul 21, 2007, 5:18:42 AM7/21/07
to ge...@googlegroups.com
Hi,

I'm wondering if you plan to integrate this patch for geonames ?
I wrote a script that use it to fetch coordinates from iCal files, and
I'll be happy to release it without including a modified version of
geopy.

Best,

Alex

markdeblois

unread,
Sep 10, 2007, 9:46:11 AM9/10/07
to geopy
Hi Alex,

Sounds like I need exactly your modified python script. For a lot of
global addresses it seems geonames is very good, though not the
postalcodesearch but the general one. Using the link I cannot find the
modified file you mention. Could you please send it to me or am I
missing something obvious here?!

cheers,
Mark

On Jul 21, 10:18 am, "Alexandre Passant" <a...@passant.org> wrote:
> Hi,
>
> I'm wondering if you plan to integrate this patch forgeonames?
> I wrote a script that use it to fetch coordinates from iCal files, and
> I'll be happy to release it without including a modified version of
> geopy.
>
> Best,
>
> Alex
>

> On 3/11/07, Alexandre Passant <a...@passant.org> wrote:
>
> > Hi,
>
> > A little update to the previous patch, so that it now adds geonameId
> > to results if using the 'search' method
>

> > Still available athttp://apassant.net/home/2007/01/geopy-geonames


>
> > Best,
>
> > Alex.
>
> > On 1/5/07, Brian Beck <exo...@gmail.com> wrote:
>
> > > Alexandre Passant wrote:
> > > > I hacked the lib so that we can pass a resource option to the
> > > > geocoders.GeoNames() method.
> > > > resource='search' will search the basic service [2], while the default
> > > > option (to be coherent with the current API) is to use the
> > > > "postalCodeSearch" service.
>
> > > > Patch is available at [7], as well as the rewritten geocoders.py
> > > > (based on current SVN version).
>

> > > Good idea,GeoNamessupport definitely needed some love. Thanks for

Alexandre Passant

unread,
Sep 10, 2007, 4:03:44 PM9/10/07
to ge...@googlegroups.com
Hi,

On 9/10/07, markdeblois <in...@envisionit.nl> wrote:
>
> Hi Alex,
>
> Sounds like I need exactly your modified python script. For a lot of
> global addresses it seems geonames is very good, though not the
> postalcodesearch but the general one. Using the link I cannot find the
> modified file you mention. Could you please send it to me or am I
> missing something obvious here?!

The files (both diff and .py) are available at

http://apassant.net/home/2007/01/geopy-geonames/

Hope it helps !

BTW, Brian, any chance it will be in next geopy release ?

Best,

Alex

markdeblois

unread,
Sep 11, 2007, 11:05:53 AM9/11/07
to geopy
Hi Alex,

Thanks for the quick response. The link you mention does not contain
the modified geocoders.py (not sure what it does contain). Or am I
supposed to run the diff on it somehow (haven't come across a diff
before). Or is there another place where I can find the altered file?!

Once I have the file up and running, I presume I have to run it
something like:

gn = geocoders.GeoNames(resource='search') ????

I presume this main search will return several results in some cases,
is this something which you have tackled as well?!

thanks again,

Mark

On Sep 10, 9:03 pm, "Alexandre Passant" <a...@passant.org> wrote:
> Hi,
>

> On 9/10/07, markdeblois <i...@envisionit.nl> wrote:
>
>
>
> > Hi Alex,
>
> > Sounds like I need exactly your modified python script. For a lot of

> > global addresses it seemsgeonamesis very good, though not the

Reply all
Reply to author
Forward
0 new messages