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

How to narrow the result from Nominatim with only cities and countries, no additional areas?

1

I'm trying to get WKT polygons of cities and countries from Nominatim (for example, Paris and France). I send a GET request but it returns me several results named "Paris". How may I narrow results only to the capital. Here's my request url:

http://nominatim.openstreetmap.org/search/fr/paris?format=json&polygon_geojson=1

And I get an array of 10 objects, only one is the capital,

class: "boundary", type: "administrative".

The rest are:

class: "place", type: "isolated_dwelling"
class: "place", type: "hamlet",
class: "place", type: "neighbourhood"
and so on...

How to select only the desired city and only the desired country ignoring rest of results?

asked 08 Nov '13, 16:10

green10701's gravatar image

green10701
16111
accept rate: 0%


One Answer:

2

There's probably no guaranteed way to do this but several things that can help:

  • Limit the number of results to one by adding &limit=1 (example)
  • Request only certain feature types by adding &featuretype=city (example)
  • Request only cities named "Paris" in a country named "France" by using as structured query: search?city=Paris (example)

answered 09 Nov '13, 15:01

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 09 Nov '13, 15:03

Apparently the featuretype parameter was removed https://github.com/osm-search/Nominatim/issues/1938

(16 Sep '22, 05:22) cyberixae