Isochrone calculations when "max_speed" is missing

I assume isochrone takes the “max_speed” detail into account, but for many cities I see that the max_speed is entirely missing.

In such cases, which speed does graphHopper use to calculate the speeds?

GraphHopper does not use the max_speed tags for route calculations. It rather assumes an average speed depending on the type of roads. See e.g. the defaultSpeedMap in CarFlagEncoder.java. The max_speed encoded values can be shown as path details but do not affect the routing.

I see, thanks for clarifying.

As a follow-up, is there a way to customize the defaultSpeedMap from a yml file?

From what I gathered, the config file only supports adjusting the Max Speed (and multipliers) of a profile, but not to average speed. Is that correct?

Sorry, I have to correct myself here. GraphHopper does make use of the maxspeed tags to potentially reduce the speed below the values in defaultSpeedMap. But if there is no maxspeed tag it simply uses the default speed.

No, you can customize the average speed (and actually you cannot customize the max speed).
This is documented here: graphhopper/docs/core/profiles.md at master · graphhopper/graphhopper · GitHub
and details about custom models are described here: graphhopper/docs/core/custom-models.md at master · graphhopper/graphhopper · GitHub

So you cannot customize the defaultSpeedMap from yml, but you can customize a multiplier for the average speed.

Also note that /isochrone does not support custom models yet, but you can still define custom models on the server side (via yml) and use them with /isochrone.

For example:

profiles:
  - name: my_custom_profile
    vehicle: car
    weighting: custom
    custom_model: {
      "speed": [
        {
          "if": "road_class == MOTORWAY",
          "multiply_by": 0.8
        }
      ]               
    }

means that the default GraphHopper car speeds (according to CarFlagEncoder) will be used (because of vehicle: car) and for all OSM ways with highway=motorway the speed will be multiplied by 0.8.

After running the import you can then use this profile via /isochrone?profile=my_custom_profile...

Perhaps I was looking at an outdated documentation, but instead of a multiplier property, I believe you can set a limit_to property- which is the equivalent to a “max speed”(?)

Yes in the most recent version (since 3.0, May 2021) you can do something like:

custom_model: {
      "speed": [
        {
          "if": "road_class == MOTORWAY",
          "limit_to": 80
        }
      ]               
    }

which caps the default speed at 80km/h (e.g. if it was 120 it would now be 80, but if it was 70 it would remain 70). So this is a ‘maximum speed’ in a way but it is not directly related to the maxspeed OSM tag. Btw maybe I did not understand what you meant with "max_speed" detail in the first place?

Which GraphHopper version are you using? Re-reading your comments you are probably using 2.0 or older and before 3.0 there actually was a special max_speed section for custom models. Using this you can limit the speed (just like limit_to for GraphHopper 3.0), but again this is not directly related to the maxspeed OSM tag. I thought you were referring to the OSM tags, because you were wondering what happens when “max_speed is missing entirely for many cities”.

Right, I probably wasn’t clear enough. I was referring the the details tag originally and the custom_model the second time.

Thanks for clarifying all this, it’s a lot clearer how the system works now.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.