Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
How to smooth elevation gain from GPS Points

I have a big problem here:

I have an array of gps datas and it's necessary to calculate some informations, I did it all except for the total elevation gain in the route. There's an array like this [825.23423, 827.39420, 828.19319, ...] that storage the elevation of each gps point passed and I need to calculate the full sum. The problem is that gps is not so accurate and sometimes gives some incorrect elevations, and it's making the sum get wrong. I tried many ways to smooth the data, here are some:

  • Set a minimum value to sum the elevation gain
  • Get "sub-arrays" and made the media of them to sum the elevation gain after.
  • Get "sub-arrays" and pop and shift the uncommon values to sum after that.
  • And the actual way I mixed all, it got better but not even close to the perfect:
const getMediaFixed = (values: number[]) => {
      values.sort((a, b) => {
        return a - b;
      });
      values.pop();
      values.shift();
      const media = values.reduce((a, b) => a + b) / values.length;
      return media;
    };

    let last: number = elevations[0];
    let elevationSum = 0;
    // let countLimit: number = 1;
    for (let i = 0; i < elevations.length - 5; i += 5) {
      let media: number;
      if (i <= elevations.length - 4) {
        media = getMediaFixed([
          elevations[i],
          elevations[i + 1],
          elevations[i + 2],
          elevations[i + 3],
          elevations[i + 4],
        ]);
      } else {
        media = elevations[i];
      }

      const temp = 0.75 * last + 0.25 * media;
      if (temp - last > 0) {
        elevationSum += temp - last;
      }
      last = temp;
    }

The point is that it's not working anyway.

Here's a site that works perfectly calculating from a GPX File (I couldn't find the contact to ask for help): https://www.trackreport.net

I appreciate any ideas to improve the code!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I made it using the exponential moving average to smooth the array with elevations and then I used 1 meter to ignore the bugs!

Thanks.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!