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 ( http://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

accept rate: 0%

edited 12 Sep '16, 08:32

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

This should work:


permanent link

answered 12 Sep '16, 10:58

mtmail's gravatar image

accept rate: 31%

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

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

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
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Sep '16, 08:29

question was seen: 3,495 times

last updated: 14 Sep '16, 00:38

powered by OSQA