Avoid countries? Yes we can!

Border restrictions are here!

Have you ever wanted to route between countries in Europe but only cross Schengen borders? Or maybe route from Detroit to Buffalo without crossing into Canada? Well now with openrouteservice you can! With the introduction of the new border crossing restrictions feature on driving profiles, you can tell the openrouteservice API to avoid all borders, controlled borders, or even specific countries.

To make use of this feature, simply pass a parameter called “avoid_borders” with a value of “all” or “controlled” into the options json object. For example,

...&options={"avoid_borders":"controlled"}&...

would tell the routing engine to avoid crossing controlled borders, but still allow crossing of open borders (i.e. Schengen borders). To avoid specific countries, you can make use of the avoid_countries option. For that,

...&options={"avoid_countries":"17|117"}&...

tells the service to avoid crossing into Belgium and Luxembourg.

Restricting borders is useful for logistics companies all over the world to avoid national driving restrictions and/or unnecessary delays at customs checkpoints. Below is an example screenshot for a route from Ludwigshafen, Germany, to Milan, Italy, detouring over Austria to avoid Switzerland. A common use case for central European companies, Swiss customs is known to behave rather particular (no offense, Switzerland, we all love you) [ Try it yourself ].

A full list of the codes to use for the countries can be found on GitHub. And to figure out how to use the API please visit our developers documentation.

If you have any suggestions or feedback please feel free to drop us a note via @twitter.