Restricting Borders in openrouteservice
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. 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
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:
https://api.openrouteservice.org/isochrones?api_key=your-api-key&locations=8.34234%2C48.23424&profile=driving-car&range=600%2C%201800&attributes=total_pop
which will respond the total population count in this polygon:
"properties":{"group_index":0,
"value":600,
"center":[8.34234,48.23424],
"total_pop":8373,"total_area_km":43.9361
},...
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)!
—