Calculate altitude differences per Kilometer

Code junkies hangout here

Moderators: ChriThor, LXF moderators

Calculate altitude differences per Kilometer

Postby neilj » Sat May 14, 2011 4:35 am

I am trying to develop a pacing chart for runners in php. For this i require the difference in the altitude for each kilometer.

I have used a website to trace a route of the Comrades Marathon, an 89km race from Durban to Pietermaritzburg in KwaZulu Natal, South Africa. It is the most important race in the South African running calendar.

From the site I can download 2 files as GPX (Google Earth and others) or TCX (Garmin training center)

The gpx looks like this

<?xml version="1.0"?>
<trkpt lat="-29.85818" lon="31.02515"></trkpt>
<trkpt lat="-29.85981" lon="31.02209"></trkpt>
<trkpt lat="-29.86025" lon="31.01924"></trkpt>
<trkpt lat="-29.86082" lon="31.01580"></trkpt>
<trkpt lat="-29.61087" lon="30.38074"></trkpt>
<trkpt lat="-29.61084" lon="30.38092"></trkpt>

and the tcx like this

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<TrainingCenterDatabase xmlns="" xmlns:xsi="" xsi:schemaLocation=" ... basev2.xsd">

<CourseFolder Name="Courses">

<AverageHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">
<MaximumHeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">
<HeartRateBpm xsi:type="HeartRateInBeatsPerMinute_t">

<Author xsi:type="Application_t">
<Name>Garmin Training Center(TM)</Name>
<Time>Mar 15 2007, 12:31:45</Time>


I need to plot the run and then extract the altitude for each kilometer from the start.

Can anyone help with this.
LXF regular
Posts: 106
Joined: Sun Oct 23, 2005 1:12 pm
Location: Kloof,KwaZulu Natal,South Africa

Postby MartyBartfast » Sat May 14, 2011 7:10 am

Cant help with the php, but if you don't want to reinvent the wheel have a look at which may well do what you want.
I have been touched by his noodly appendage.
LXF regular
Posts: 842
Joined: Mon Aug 22, 2005 7:25 am
Location: Hants, UK

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests