GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
bounding box  XML
Forum Index -> General
Author Message
piglettravel



Joined: 06/07/2013 05:29:57
Messages: 3
Offline

The API documentation for http://www.geonames.org/export/geonames-search.html says that its possible to search within a bounding box defined as east,west,north,south which is a float. However, I cannot understand how this might be used. Does east correspond to a lat,lng which marks the east point or is it something else ? Can someone please provide some hints on how to use the bounding box feature of the Geonames Search API ?
saphir



Joined: 05/06/2010 22:44:39
Messages: 130
Offline

Hi piglet

A bounding box is a rectangle, defined by the westernmost and the easternmost longitudes, and the northernmost and the southernmost latitudes, where the searched territory fits completely in.
As the earth is no longer a flat disk... it is a spherical rectangle, i.e. the two latitudes are parallels, while the two longitudes are not.

This service is not meant for searching a whole country. But to illustrate a problem, go to Google Earth (with 'grid' view on) and look at >>>

- An isolated and compact island like Iceland has a bounding box that contains only Icelandic features.

- The bounding box of Norway, a long, somehow 'oblique' country, will contain much more features from Sweden, Finland, Russia and Estonia than from Norway.

Regards
Urs
piglettravel



Joined: 06/07/2013 05:29:57
Messages: 3
Offline

Okay, but somehow it does not seem to be working for me. For example, if I do something like http://api.geonames.org/citiesJSON?north=54.85764&south=-50.373496&east=-0.626221&west=17.611084&username=demo I expect get cities roughly within Western Europe. Is it not working because its too big a region or is it due to something else ? Can you please educate me ?
saphir



Joined: 05/06/2010 22:44:39
Messages: 130
Offline

Hi piglet,

There is an error in your URL string >>> You certainly would expect an answer about northern Europe - right?
Your bounding box' southern limit is -50.3xxx >>>
Negative latitudes are in the southern hemisphere, you search between the Baltic Sea and the South Atlantic (between Africa and Antarctica).
Make this limit positive!

Test with an increased number of returned rows, the default is 10 rows.
The argument is &maxRows=xx& >>> see the documentation.

But I don't know if such a big area in a densely packed Europe may return useful results for your purposes...

Cheers,
Urs


PS 02:30
There is even a second error I did overlook before >>>

Longitudes are counted from the 0°-Meridian at Greenwich UK
To the West of Greenwich (direction USA) longitudes are negative from 0° to -180°
To the East (direction continental Europe) they are positive from 0° to +180°

You inverted the western/left and the eastern/right limits of the bounding box.
You are not searching from the UK to Poland, but from Poland eastwards around the earth through the Pacific Ocean to the UK.

The URL should look like this >> http://api.geonames.org/citiesJSON?north=54.85764&south=50.373496&east=17.6&west=-0.62&maxRows=20&username=demo
piglettravel



Joined: 06/07/2013 05:29:57
Messages: 3
Offline

Yes !!!

Dumb of me. Thanks for pointing it out...
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team