This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Nominatim search filtering

1

I have task - finding coordinate for address, and i always know city for address.

How i can filter search for one city? Documentation indicated request parameters city and country ( https://wiki.openstreetmap.org/wiki/Nominatim#Parameters ), but when i use it, result of search does not depend on it.

For example: http://nominatim.openstreetmap.org/search?q=tower&city=London&format=json

Where am I wrong?

asked 12 Sep '16, 08:29

vnk's gravatar image

vnk
31113
accept rate: 0%

edited 12 Sep '16, 08:32


One Answer:

1

The documentation also says "DO NOT COMBINE WITH q=<query> PARAMETER." :)

This should work:

http://nominatim.openstreetmap.org/search?street=tower&city=London&countrycodes=GB&format=json

answered 12 Sep '16, 10:58

mtmail's gravatar image

mtmail
4.8k1574
accept rate: 27%

Oops.. Thanks, I didn't notice..

But is there a way to filter the results not strictly comply with the required city?

For example http://nominatim.openstreetmap.org/search?street=place&city=Washington&countrycodes=US&format=html

return results from more then one city

(12 Sep '16, 12:21) vnk

I'm afraid not. Your best alternative is to either set &viewbox and &bounded=1 (of course that requires you know the location and size of the city first). Or look at all results to see how close they are to the desired city.

(12 Sep '16, 13:49) mtmail

And new problem, I don't understand how it works or it does not work properly?

viewbox without restrict: http://nominatim.openstreetmap.org/search?street=place&city=Washington&countrycodes=US&viewbox=44.86366%2C-127.01294%2C50.05714%2C-111.41235&format=html Four results, but first not in viewbox.

restrict query with bounded=1 http://nominatim.openstreetmap.org/search?street=place&city=Washington&countrycodes=US&viewbox=44.86366%2C-127.01294%2C50.05714%2C-111.41235&bounded=1&format=html and nothing result :(

And same behavior when i use query: http://nominatim.openstreetmap.org/search?q=place%2C+Washington&viewbox=44.86366%2C-127.01294%2C50.05714%2C-111.41235&bounded=1&format=html in this request search results wihout bounded working good, but some other requests without bounded restrict return results also with data out of the viewbox :(

(13 Sep '16, 01:12) vnk
2

You mixed up latitude and longitude here. The viewbox parameter requires <left>,<top>,<right>,<bottom>. http://nominatim.openstreetmap.org/search?street=place&city=Washington&countrycodes=US&viewbox=-127.012940,50.057140,-111.412350,44.863660&bounded=1

(13 Sep '16, 12:57) mtmail
2

Actually the user interface on that page is misleading. We'll change that now https://trac.openstreetmap.org/ticket/5422

(13 Sep '16, 13:22) mtmail

Great! Big thanks!

(14 Sep '16, 00:38) vnk
showing 5 of 6 show 1 more comments

Source code available on GitHub .