0

Is it possible to download the polygons of countries from OpenStreetMap using Nominatim web API? If so, how should I query its points?

In the example responses from Nominatim on OpenStreetMap wiki there is a polygonpoints property (attribute) on place object (tag), but it's not always present in search results when querying for countries. Also, what happens when the country "consists" of more than one polygon - several islands, for instance, can I query all of them?

If it's impossible to do with Nominatim, is there any other freely available API with such functionality?

2
  • AS per the Tour there should be only one question asked per question.
    – PolyGeo
    Dec 14, 2016 at 21:12
  • I think Overpass API would be the better approach here.
    – scai
    Dec 15, 2016 at 9:35

1 Answer 1

4

It think it is possible with Nominatim, take a look at the query parameters listed in the documentation: The interesting parameters for you are the ones starting with polygon_, depending on what format you desire you can add polygon_geojson=1 or polygon_kml=1 (or the other ones) to your query.

If a country consists of several islands/polygons they are included as well, take for example Spain. The resulting geometry is a MultiPolygon for GeoJSON, MultiGeometry for KML and so on:

enter image description here

The query URLs may look like this:

http://nominatim.openstreetmap.org/search?country=Spain&polygon_geojson=1&format=json
http://nominatim.openstreetmap.org/search?country=Spain&polygon_kml=1&format=json

Using country= instead of using the general q= as the search parameter seemed to yield better results for your use case.

Not the answer you're looking for? Browse other questions tagged or ask your own question.