3

I'm new to OSM and the overpass API. I've tried using

[out:csv("name:en")];relation["amenity"="embassy"];out;

In order to get the list of all of the embassies mentioned, but the result of the query only produces 38 embassies. That can't be right. Is there something wrong with my query or this is a limitation of the database or something else?

2 Answers 2

8

It's because you are expecting that embassy tags are set on a relation. Looking at TagInfo for amenity=embassy, you will see that nearly no relations were set with this key/value combination.

It's in fact normal because if you look on the right panel of the OpenStreetMap wiki for the tag, like in the following screenshot, you will see that relations should not be tagged with this key/value combination (part "Used on these elements")

enter image description here

To fix, your issue, you should clic on the link in the bottom-right named overpass-turbo (see my second screenshot below) and remove the reference to bbox. The remaining job will be to change the syntax to export to CSV instead of the default [out:json].

Overpass turbo link

2
  • overpass-turbo hasn't been working for me, it freezes on the loading screen. I use the query form page to test, my queries. I see what you mean that there are very few embassies that are shown as relations. It looks like embassies are split into nodes and ways, is there a way to get the embassies from nodes and ways in one query? Feb 5, 2017 at 23:07
  • 2
    Just exchange relation with way and node in your query. You need two separate API calls for that. Don't rely on the name:en key to be set, some embassies might just have the name tag in the local language.
    – AndreJ
    Feb 6, 2017 at 6:37
3

As already explained by ThomasG77 you need to query for nodes, ways and relations. However there is no need for multiple queries, just use the following one:

[out:csv("name:en", "name")][timeout:120];
(
  node["amenity"="embassy"];
  way["amenity"="embassy"];
  relation["amenity"="embassy"];
);
out body;
>;
out skel qt;

You can download the result here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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