How can I find all countries that are neighbours (share a border point or line) of a given country (eg. germany) using Overpass?

  • Is this a one off activity, or do you want to integrate this in some app and run it on a regular basis by many users? This kind of analysis is very expensive, and I don't want to post something that will create too much load on public instances. Also, what exactly do you mean by neighbors? Would Russia be a neighbor of the US?
    – mmd
    Sep 2 '19 at 16:38
  • I'm interested in the syntax in the first place. The query will be extended to neighbouring regions or states in the next step. Results will be cached forever, since I don't need to track future changes. By neighbours I mean countries that share a border line.
    – GeoMapper
    Sep 3 '19 at 0:18

The syntax for overpass turbo is as follows (the example deliberately uses admin_level=4 which will return "Bundesländer", rather than neighboring countries to keep the data volume small. If you want neighboring countries you need to adjust the admin level).

out geom;
  • Thank you very much. Is there any way to control the output? I changed the output to json (using [out:json] in the first line) and the query output to meta (using out meta; in the last line) but still get a lot more data than necessary. I'm basically only interested in the name and pivot coordinates of each result. Skipping all the "way" nodes would already be a huge plus.
    – GeoMapper
    Sep 4 '19 at 23:52
  • Try replacing out geom; by out center tags;
    – mmd
    Sep 5 '19 at 8:32
  • Very nice, thank you for the help!
    – GeoMapper
    Sep 5 '19 at 21:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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