Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

120
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda