I searched the forum, but can’t seem to find a similar issue. Is there a way to exclude certain areas from the routing process, for example a traffic congested area, or i have to make it on my own? I think it would be a really helpful feature.
the openrouteservice API has this feature - unfortunately it is a bit hidden
Have a look at the API-docs for directions, under options → avoid_polygons.
It’s also available in the python, js and r-sdk and in the Advanced Directions-Tab in the QGIS Plugin, and will come to the processing plugins soon.
take a look at this example using avoid_polygons.
Both GeoJSON Polygons and MultiPolygons are supported and has to be passed in the options parameter like:
I am trying to implement this, but keep getting this error message: openrouteservice.exceptions.ApiError: 400 ({'error': {'code': 2000, 'message': "Parameter 'avoid_polygons' has incorrect value or format."}, 'info': {'engine': {'version': '6.6.1', 'build_date': '2021-07-05T10:57:48Z'}, 'timestamp': 1636461297917}})
My code is quite simple, could you take a look?
import openrouteservice as ors
import folium
coords = ((x, y), (x1, y1))
client = ors.Client(key='blah') # Specify your personal API key
routes = client.directions(coords, profile='foot-walking',options= {
"avoid_polygons": {
"type": "Polygon",
"coordinates": [
[x2, y2],[x3, y3],[x4, y4],[x5, y5]
]}})
print(routes)
Does this error indicate an error in my data or in the syntax of the code? : openrouteservice.exceptions.ApiError: 400 ({'error': {'code': 2000, 'message': "Parameter 'avoid_polygons' has incorrect value or format."}, 'info': {'engine': {'version': '6.6.1', 'build_date': '2021-07-05T10:5