[GIS] How to narrow the result from Nominatim with only cities and countries, no additional areas with the same name

nominatimopenstreetmappolygon

I'm trying to get WKT or GeoJson 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" or "France". How may I narrow results only to a capital and a country. 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 where 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 with the same name?

Best Answer

As you seem to try to getting bulk data, you are encouraged to append the email=... param to avoid beein blocked.
You can use various place=* tags to prefilter your results or even limit your result.

As Nominatim isn't build as a data provider, you might use to get the boundary polygons here:
http://download.geofabrik.de/europe/france.html
http://wiki.openstreetmap.org/wiki/WIWOSM

Related Question