Avoiding Countries, Fetching Population Statistics and Responding in GeoJSON with Openrouteservice!

Restricting Borders in openrouteservice

Openrouteservice Avoiding Switzerland
Openrouteservice Avoiding Switzerland

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,


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,


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. This is an example 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).

Population Statistics for Isochrones

GHSL - Global Human Settlement Layer
GHSL – Global Human Settlement Layer

We are also excited about one handy new feature for the isochrones API: From now on, you can optionally return the population count for each isochrone you’re calculating. This is an imperative step for inclusive reachability analysis.

The dataset, which makes this possible, is published by the European Commission in their Global Human Settlement Program. It features 250 m x 250 m cell size across the globe and is the finest grained dataset of its kind.

To access this feature in runtime you have to specify it as attribute in the isochrone request:


which will respond the total population count in this polygon:


Responding in GeoJSON

Last but not least, we have finally introduced the much longed feature to respond in GeoJSON. This is especially handy for a quick look at the geometry of routes. The response can be directly imported into QGIS via “add vector layer”, selecting “protocol” as the source type, and entering the url (with the format=geojson url parameter)!

Consuming the ORS API via QGIS
Consuming the ORS API via QGIS

ORS on GitHub

ORS 4.5 Changelog

ORS Route Planning

ORS API Documentation