You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#1953 improves the resolution of elevation profiles so that they don't miss real elevation changes along routes, but it also makes the profile more susceptible to noise artificially inflating total elevation gain/loss metrics.
For example, going around this turn in the Danube Valley should be flat, but any method that relies solely on DEM data will show it going up the side of the valley and back down to the river: .
Also, see this example described in this blog post which should be a steady ascent and descent. Without smoothing, the switchbacks appear to go up and down the side of the hill:
With graph.elevation.smoothing the total ascent/descent and switchback gain/loss are reduced, but it introduces some artifacts to the elevation profile that look like shear cliffs:
We should see if there is a way to improve elevation profile smoothing to account for cases like these while maintaining an accurate looking profile.
See other examples and comparisons to other providers in comments on #1953.
when we smooth the profile, get the min and max elevation sample used during bilinear interpolation and use that range to guess what elevation the road should be at, assuming roads are typically built to maintain a steady grade.
during smoothing, do polyline simplification on the 2D elevation vs. distance profile of the segment, and assign elevations to points by interpolating along that (maybe using the DEM elevation range as the tolerance for each point)
I think we should check whether the gradient of the path exceeds a certain threshold at any point. This should be a fairly safe criterion, otherwise the route would no longer be passable by cars.
There's also probably some low hanging fruit with the existing elevation smoothing code. From my understanding it does a windowed average of all points within 150m on the segment. This results in a couple of issues:
points are denser around corners and each is given equal weight, so it ends up "pulling" nearby samples toward the turn (weighted average based on distance between points might help)
if a path is going up a hill, and there is an intersection halfway up, the windowed average on the uphill side of the intersection get "pulled up" because they don't take into account samples from lower on the hill, and points on the downhill side get "pulled down" resulting in a sharp increase at that intersection
the smoothing code changes the elevation samples as it iterates through them, which leads to elevation profiles looking different based on the direction the way is processed
Likely, these don't impact overall elevation gain/loss much, they just result in issues with the profile shape.
One idea off the top of my head would to filter out the noise. So we should probably look at filtering out outliers.
For example for an elevation profile that looks like this:
______/\______
We should filter out that bump.
But like this:
__
____/ \______
We should keep it.
So for example, if there is just one point that is different than the two surrounding points, then maybe the center point is wrong.
This results in a couple of issues
Yes, a major issue, IIRC, is that the algorithm doesn't touch the tower nodes and I think we made some compromises there in regards to speed vs. accuracy. But in general, yes the algorithm certainly has potential for improvement :).
I think we should check whether the gradient of the path exceeds a certain threshold at any point.
I had a similar idea in the past. And I think, back then I checked for slopes > 25%, and there weren't that many, that were obviously wrong. I mean there a lot of paths up the mountain that are that steep. So that got a bit tricky to use it as rule of thumb.
during smoothing, do polyline simplification on the 2D elevation vs. distance profile of the segment, and assign elevations to points by interpolating along that (maybe using the DEM elevation range as the tolerance for each point)
Could you elaborate on that idea? I am not sure I am understanding it.
during smoothing, do polyline simplification on the 2D elevation vs. distance profile of the segment, and assign elevations to points by interpolating along that (maybe using the DEM elevation range as the tolerance for each point)
Could you elaborate on that idea? I am not sure I am understanding it.
After #1953 gets merged, the last step processing a way is that we do 3D polyline simplification that throws out any point that changes the 3d polyline by less than some tolerance. We are talking about setting the elevation tolerance to 3-5m, but that still retains the "exact" elevation at each point when going around turns. During the smoothing step, we could also run 2D polyline simplification on just the elevation profile to keep the overall shape but throw out noise in the middle.
The "DEM elevation range" idea is that each point lies somewhere between 4 neighboring elevation samples from the DEM data. You know the ground rises from the min to max neighboring value, but you don't know exactly where the rise happens, so you treat the entire possible elevation range as the tolerance for that point when doing polyline simplification or another smoothing technique. For example, if a road at 1000m goes along the edge of a cliff, every time you sample DEM data, 1 or 2 samples are in the canyon at 800-900m and the rest are at 1000m along the rim. The profile using bilinear interpolation oscillates between 900 and 1000m, but if you simplify that keeping in mind the "range" of each point, then you can throw out all of those artificial drops.
I think we need to distinguish between "noise" which for me is lots of tiny changes in elevation falsifying the accumulated ascend/descend sums and real "errors" caused by outliers in the elevation profile.
I also started investigating this today again as I was rather unhappy with the elevation profiles I got. I made a comparison of some data sources. The first route I considered was the street parallel to the danube above. I think it has a very similar problem to #3031. That is, if the route travels along a steep cliff and the discretization of the dem is not parallel to the route (and cliff), a lot of noise is accumulated through the discretization:
All images were scaled so that black is 580m and white is 750m.
Note that the last three are digital terrain models, they thus are not raw satellite signals but already try to remove buildings and canopy to directly estimate terrain height. They also seem to smooth the elevation around the street.
Using a DTM is even more important in the city. For example, consider this route past potsdamer platz (graphhopper link). Graphhopper says we go up 17m and go down 20m. This is exclusively because the srtm data does not distinguish between hills and buildings:
SRTM (3 Arc seconds)
EU-DTM (2 Arc Seconds)
EU-DEM (1 Arc Seconds)
This time, black is 40m and white is 60m.
In my opinion EU-DEM and EU-DTM seem to be the best step forward. Their data is quite a step up from SRTM while still covering a large continuent. EU-DTM of course will be quite a lot better in cities. EU-DEM might be slightly better in the countryside.
In my opinion EU-DEM and EU-DTM seem to be the best step forward.
Isn't EU-DTM including EU-DEM? From what I understand it used several data sets like EU-DEM and machine learning.
EU-DTM is under CC BY 4.0 and the different data sets seem to have also open licenses, so it seems we could use that.
ASTER is also part of the data sources used to create NASADEM (#3147). I also think that EU-DEM is already superseded by COP-DEM and its GLO-30 model.
A digital terrain model (DTM) would be the best fit for routing purposes, as it excludes buildings and tree cover. These are still part of the "raw" digital surface models (DSM).
Then there is EuroDEM (Not EU-DEM, my bad), which is actually a DTM. It has 2 arc seconds resolution. I believe it uses high quality official sources for buildings with which it does the post-processing.
There is also EU-DTM which uses machine learning to predict terreain elevation at 30m resolution. None of the datasets used seem to contain building outlines. When looking at the Potsdamer Platz route, it also does not seem to remove the noise due to the buildings that well (see below).
Mapsforeurope: Euro-Dem
OpenTopography: Euro-DTM
GLO-30 Donau
GLO-30 Potsdamer Platz
GLO-30 Stelvio
EuroDEM (DTM) Stelvio
While the DTM is thus much better in cities, the higher resolution of GLO-30 definitely would be beneficial around very steep areas. I did not find good sources for Nasadem or Aster, but I also do not know why I would expect them to be better than GLO-30.
I thus suggest to first do a PR for a GLO-30 provider, for which a AWS Open Data mirror exists. Having the option to use a DTM like the one from www.mapsforeurope.org would be great. However there is no nice mirror at the moment and the file requires some post-processing (projection and tiling). One could of course also implement this provider and just explain the necessary manual work in the documentation.
Let me know what you think about this, then I'll try to get to work soon. If you find good data sources for ASTER or NASADEM or would prefer these for some reasons please let me know too.
(Sorry for the very long posts with screenshots again. Let me know if you think there is a better way to share these images.)
GLO-30 sounds like a good replacement for cgiar. Especially since there is a mirror (and cgiar is not cleaned up regarding buildings too, if I understand it correctly).
I wonder, will we be able to replace GMTED too or should we continue using MultiSourceElevationProvider and just use GLO30 instead of CGIAR?
update, btw: it seems that mapterhorn pmtiles includes this and data with higher resolution if available. Using zoom=12 this creates a fantastic elevation profile for the provided example with a very small incline and decline:
(only the ledge at 48.09424,9.103269 seems to leak slightly into it)
Activity
msbarry commentedon May 9, 2020
A few ideas off the top of my head:
otbutz commentedon May 11, 2020
I think we should check whether the gradient of the path exceeds a certain threshold at any point. This should be a fairly safe criterion, otherwise the route would no longer be passable by cars.
For reference: https://en.wikipedia.org/wiki/Baldwin_Street (gradient of 35%)
msbarry commentedon May 11, 2020
We'll have to take into account what kind of road as well, I know I've done at least a few hiking trails that exceed 35% for extended periods of time https://onthegomap.com/s/i76rib2u
msbarry commentedon May 11, 2020
There's also probably some low hanging fruit with the existing elevation smoothing code. From my understanding it does a windowed average of all points within 150m on the segment. This results in a couple of issues:
Likely, these don't impact overall elevation gain/loss much, they just result in issues with the profile shape.
boldtrn commentedon May 11, 2020
One idea off the top of my head would to filter out the noise. So we should probably look at filtering out outliers.
For example for an elevation profile that looks like this:
We should filter out that bump.
But like this:
We should keep it.
So for example, if there is just one point that is different than the two surrounding points, then maybe the center point is wrong.
Yes, a major issue, IIRC, is that the algorithm doesn't touch the tower nodes and I think we made some compromises there in regards to speed vs. accuracy. But in general, yes the algorithm certainly has potential for improvement :).
I had a similar idea in the past. And I think, back then I checked for slopes > 25%, and there weren't that many, that were obviously wrong. I mean there a lot of paths up the mountain that are that steep. So that got a bit tricky to use it as rule of thumb.
Could you elaborate on that idea? I am not sure I am understanding it.
msbarry commentedon May 12, 2020
After #1953 gets merged, the last step processing a way is that we do 3D polyline simplification that throws out any point that changes the 3d polyline by less than some tolerance. We are talking about setting the elevation tolerance to 3-5m, but that still retains the "exact" elevation at each point when going around turns. During the smoothing step, we could also run 2D polyline simplification on just the elevation profile to keep the overall shape but throw out noise in the middle.
The "DEM elevation range" idea is that each point lies somewhere between 4 neighboring elevation samples from the DEM data. You know the ground rises from the min to max neighboring value, but you don't know exactly where the rise happens, so you treat the entire possible elevation range as the tolerance for that point when doing polyline simplification or another smoothing technique. For example, if a road at 1000m goes along the edge of a cliff, every time you sample DEM data, 1 or 2 samples are in the canyon at 800-900m and the rest are at 1000m along the rim. The profile using bilinear interpolation oscillates between 900 and 1000m, but if you simplify that keeping in mind the "range" of each point, then you can throw out all of those artificial drops.
otbutz commentedon May 12, 2020
I think we need to distinguish between "noise" which for me is lots of tiny changes in elevation falsifying the accumulated ascend/descend sums and real "errors" caused by outliers in the elevation profile.
We'll probably end up with a two phase process:
wltrr commentedon Dec 3, 2025
I also started investigating this today again as I was rather unhappy with the elevation profiles I got. I made a comparison of some data sources. The first route I considered was the street parallel to the danube above. I think it has a very similar problem to #3031. That is, if the route travels along a steep cliff and the discretization of the dem is not parallel to the route (and cliff), a lot of noise is accumulated through the discretization:
Track on OSM Map:
Track on SRTM from Kurviger (3 Arc seconds)
EU-DEM from OpenDem (1 Arc seconds)
DE-DTM OpenDem (1m)
EU-DTM from MapsForEurope (2 Arc second)
BW-DTM OpenGeoData-BW (1m resolution)
All images were scaled so that black is 580m and white is 750m.
Note that the last three are digital terrain models, they thus are not raw satellite signals but already try to remove buildings and canopy to directly estimate terrain height. They also seem to smooth the elevation around the street.
Using a DTM is even more important in the city. For example, consider this route past potsdamer platz (graphhopper link). Graphhopper says we go up 17m and go down 20m. This is exclusively because the srtm data does not distinguish between hills and buildings:
SRTM (3 Arc seconds)
EU-DTM (2 Arc Seconds)
EU-DEM (1 Arc Seconds)
This time, black is 40m and white is 60m.
In my opinion EU-DEM and EU-DTM seem to be the best step forward. Their data is quite a step up from SRTM while still covering a large continuent. EU-DTM of course will be quite a lot better in cities. EU-DEM might be slightly better in the countryside.
karussell commentedon Dec 3, 2025
Isn't EU-DTM including EU-DEM? From what I understand it used several data sets like EU-DEM and machine learning.
EU-DTM is under CC BY 4.0 and the different data sets seem to have also open licenses, so it seems we could use that.
btw: I didn't notice until now that ASTER became public domain in 2019. Important as EU-DEM is also a derived data set from ASTER...
otbutz commentedon Dec 4, 2025
ASTER is also part of the data sources used to create NASADEM (#3147). I also think that EU-DEM is already superseded by COP-DEM and its GLO-30 model.
A digital terrain model (DTM) would be the best fit for routing purposes, as it excludes buildings and tree cover. These are still part of the "raw" digital surface models (DSM).
wltrr commentedon Dec 4, 2025
I think resolution should be the decisive factor in the choice between datasets.
Mapsforeurope: Euro-Dem

OpenTopography: Euro-DTM

GLO-30 Donau

GLO-30 Potsdamer Platz
GLO-30 Stelvio
EuroDEM (DTM) Stelvio
While the DTM is thus much better in cities, the higher resolution of GLO-30 definitely would be beneficial around very steep areas. I did not find good sources for Nasadem or Aster, but I also do not know why I would expect them to be better than GLO-30.
I thus suggest to first do a PR for a GLO-30 provider, for which a AWS Open Data mirror exists. Having the option to use a DTM like the one from www.mapsforeurope.org would be great. However there is no nice mirror at the moment and the file requires some post-processing (projection and tiling). One could of course also implement this provider and just explain the necessary manual work in the documentation.
Let me know what you think about this, then I'll try to get to work soon. If you find good data sources for ASTER or NASADEM or would prefer these for some reasons please let me know too.
(Sorry for the very long posts with screenshots again. Let me know if you think there is a better way to share these images.)
otbutz commentedon Dec 5, 2025
I very much appreciate this kind of post. They replace a gut feeling with hard data.
karussell commentedon Dec 5, 2025
GLO-30 sounds like a good replacement for cgiar. Especially since there is a mirror (and cgiar is not cleaned up regarding buildings too, if I understand it correctly).
I wonder, will we be able to replace GMTED too or should we continue using MultiSourceElevationProvider and just use GLO30 instead of CGIAR?
update, btw: it seems that mapterhorn pmtiles includes this and data with higher resolution if available. Using zoom=12 this creates a fantastic elevation profile for the provided example with a very small incline and decline:
(only the ledge at 48.09424,9.103269 seems to leak slightly into it)