I am trying to use the Nominatim API to geocode cities, with simple HTTP GET requests. I want to receive a specific number of possible matches, when available. The documentation indicates this is possible by using the "limit" parameter:

limit=integer
Limit the number of returned results.

This works as expected for most queries. For example, if I request limit=2, I get the top 2 results and if I request limit=3, I get the top 3 results. But the limit parameter behaves erratically for some queries. For example, with Sonoma California:

  • If I request limit=1, I get 1 result
  • But if I request limit=2, I still get just 1 result
  • And if I request limit=3, I suddenly get 2 results

If 2 results are available when I request limit=3, why didn't I get 2 results when I requested limit=2?

As another example, with Petaluma California:

  • If I request limit=1, I get 1 result
  • But if I request limit=2, I still get just 1 result
  • And if I request limit=3, I get 3 results this time

Why am I inconsistently not receiving as many results as I am requesting, and how can I make sure to receive the exact number I request?

asked 28 Sep '16, 06:03

gboeing's gravatar image

gboeing
1366613
accept rate: 0%


Sometimes you have several objects in OSM identifying the same place or object in reality. The simplest case is a street being split in many different OSM ways due to different characteristics. Nominatim will attempt to detect such duplicates and only return one match; this is controlled by the dedupe parameter which defaults to 1. Since the limit is, for reasons of efficiency, enforced before and not after de-duplicating, it is possible that de-duplicating leaves you with less results than requested.

In your "Sonoma" case, when limit=2 and dedupe=0 are set, Nominatim returns the ways 33162431 and 33162426 (it should return http://www.openstreetmap.org/relation/113172 instead and I don't know why it doesn't).

permanent link

answered 28 Sep '16, 07:21

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
70.9k826431106
accept rate: 24%

Thanks. Yes the dedupe parameter used in conjunction with the limit parameter does appear to give me the number of results I request, each time. However, like you mentioned in the last sentence that is an odd result.

(06 Oct '16, 18:48) gboeing
Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×555
×546
×270
×238
×25

question asked: 28 Sep '16, 06:03

question was seen: 2,339 times

last updated: 06 Oct '16, 18:48

powered by OSQA