MrMufflon / Leaflet.Elevation

Leaflet plugin to view height profile of GeoJSON- and GPX polylines using d3
http://mrmufflon.github.io/Leaflet.Elevation
MIT License
276 stars 83 forks source link

Smoothen elevation map to better represent reality #77

Open judgereini opened 6 years ago

judgereini commented 6 years ago

We are trying to realize a website for a hiking trail using leaflet with open top map. The website should also feature the elevation map for this hiking trail. We did the recording of the gpx file by hiking the trail and using a tracker to record the geo data. Our problem is that the gpx file does not 100 % perfectly match the data in the open topo map and therefore there are deviations in the elevation map that do not present the reality. Attached you'll see various unnatural spikes in the elevation map ...

How can we get rid of these spikes? Is there a way to fix this issue via configuration or additional command in Leaflet.Elevation?

leaflet_elevation
cempro commented 6 years ago

I am not really fluent with JS.Elevation but you have these interpolation options to "smooth" the graph

interpolation: "basis"

var el = L.control.elevation({   | theme: "lime-theme", //default: lime-theme   | position: "topright",   | //width: 450,   | width: (document.getElementById('map').offsetWidth-20)-50,   | //height: 80,   | height: (50+(document.getElementById('map').offsetHeight)/8),   | margins: { top: 15, right: 30, bottom: 30, left: 30 },   | useHeightIndicator: true, //if false a marker is drawn at map position   | interpolation: "basis",

  | // interpolation methods:   | // linear - piecewise linear segments, as in a polyline.   | // linear-closed - close the linear segments to form a polygon.   | // step-before - alternate between vertical and horizontal segments, as in a step function.   | // step-after - alternate between horizontal and vertical segments, as in a step function.   | // basis - a B-spline, with control point duplication on the ends.   | // basis-open - an open B-spline; may not intersect the start or end.   | // basis-closed - a closed B-spline, as in a loop.   | // bundle - equivalent to basis, except the tension parameter is used to straighten the spline.   | // cardinal - a Cardinal spline, with control point duplication on the ends.   | // cardinal-open - an open Cardinal spline; may not intersect the start or end, but will intersect other control points.   | // cardinal-closed - a closed Cardinal spline, as in a loop.   | // monotone - cubic interpolation that preserves monotonicity in y.

`

judgereini commented 6 years ago

Thanks a lot for the quick reply! We will give this a closer look and try ... ... will let you know if it has worked out.