Cannot compile expression: 'average_slope' not avilable after enabling elevation

Hello,

I’m trying to build a local GraphHopper server for a shared bicycle service, and i’m encountering a issue.

My goal is to set up a server that supports both bicycle and foot routing, as well as the round_trip feature from the Directions API.

The server ran successfully before i tried to enable elevation data in my config.yml. However, since adding the elevation settings, I’m getting an error that variables like average_slope are not available.

I have already tried deleting the graph-cache folder and rebuilding the graph multiple times, but the issue remains.

Could you please help me understand what i might be missing in my configuration?
Here is my config.yml:

graphhopper:
  datareader.file: south-korea-latest.osm.pbf
  graph.location: "graph-cache"
  vehicles:
    - bike
    - foot
  profiles:
    - name: bike
      vehicle: bike
      weighting: custom
      custom_model:
        priority:
          - {if: "bike_network == LOCAL", multiply_by: 2}
          - {if: "bike_network == MISSING", multiply_by: 0.8}
          - {if: "road_class == STEPS", multiply_by: 0}
        speed:
          - {if: "average_slope >= 10", limit_to: 5}
          - {if: "average_slope >= 5", limit_to: 10}
          - {if: "average_slope <= -5", multiply_by: 1.2}
          - {if: "bike_network == LOCAL", limit_to: 20}
  profiles_ch:
    - profile: bike
    - profile: foot
  import.osm.ignored_highways: ""
  elevation:
    provider: srtm
    cache_dir: ./srtm-cache
server:
  application_connectors:
    - type: http
      port: 8989
      bind_host: 0.0.0.0
  admin_connectors:
    - type: http
      port: 8990
      bind_host: 0.0.0.0

You need to specify all required encoded values:

1 Like

Thanks, I’ve been trying to use elevation data, but the SRTM data isn’t downloading automatically even after setting the elevation.provider and cache_dir. I tried to download the .hgt data manually and use it, but that also failed. Can you give me some advice?

You should follow the example config:

graphhopper:

  (...)

  graph.elevation.provider: srtm
  graph.elevation.cache_dir: ./srtm-cache
1 Like

Thank you so much. I could have found this in the official documentation, but I was confused because Gemini kept giving me incorrect information.

Don’t trust the hallucination machine :slightly_smiling_face:

2 Likes