Disallow certain road types for routing, e.g. "Service Road"

Is it possible to make it so that graphhopper does not utilise certain road types when computing routes? Specifically I want to turn off open street map road features Service Road.

Is this something that should be done in the code or in the data itself? E.g. I can imagine removing service roads from the dataset I pass into graphhopper.

Hi @njachowski,

You can create a new flagEncoder and add the road types you would like to disallow (e.g., “service”) to restrictedValues.

Best regards,

1 Like

Thanks @jie31best seems easy enough! I’ll give it a try.

In the meanwhile has anyone ever tried passing in customised data sets to accomplish a similar result? I see osmfilter and osmconvert could make it easy to remove the offending road features from the *.osm.pbf file before I pass it into graphhopper.

It seems like passing in a trimmed down data file could have other benefits potentially, although it comes with trade-offs as well.

An alternative is to work with TagTransform before feeding the osm to GraphHopper.


1 Like

I would create a new FlagEncoder e.g. just extending CarFlagEncoder and calling defaultSpeedMap.remove("service") in the constructor … hmmh but getFerrySpeed requires it -> you would need to call this method with a static value.

1 Like