How climbs are detected and categorised from a ride
A ride file is just a list of altitude samples, yet cycling software can say "this was a category 2 climb at 7.3 %". Here is how that works, step by step, and how to read the result.
From a ride to an altitude profile
A FIT, TCX or GPX file records altitude once a second or so, at irregular distances. Before looking for climbs, the data is resampled so that there is one altitude value every 10 metres along the route, interpolating between recorded points. Distance, not time, is the horizontal axis, which makes a 2 km climb look the same whether you rode it in 8 minutes or 14.
That profile is then smoothed with a short moving average of about ±20 m. Smoothing matters more than it seems: a barometric altimeter quantises its output (it holds a value for a few seconds and then jumps 2-3 m), and without a little smoothing every one of those steps would look like a ramp. Too much smoothing has the opposite problem, as it stretches short bumps until they pass the length minimum. ±20 m is a compromise that works for barometric altitude; altitude that comes from GPS needs far more, as explained in our guide on why ride altitude lies.
Finding the ascending stretches
The algorithm walks along the smoothed profile and cuts it into ascending stretches wherever there is a descent of 30 m or more. A small dip in the middle of a long col, a hairpin where the road flattens for a moment, a bump in the barometer: none of those end a climb. A real descent does.
Inside each stretch it looks for the sub-stretch with the most elevation gain that still meets two minimums: at least 400 m long and an average gradient of at least 2.5 %. The 400 m at 2.5 % floor is deliberately small: it is 10 m of gain, a short but real hill, and it is the lowest thing that counts as a climb.
Three clean-up rules follow:
- Trimming gentle approaches. If the first (or last) 200 m of the candidate are below 2.5 %, they are dropped. A 600 m flat-ish run-in before the real ramp should not dilute the average gradient.
- Splitting at flats. Where there is 1 km or more at under 1 %, the stretch is split in two and the procedure is repeated on what is left. A plateau in the middle of a mountain makes two climbs, not one.
- Discarding what is not cycling. Stretches covered in a car, and stretches where you were not pedalling (fewer than 20 % of the samples with cadence or power, when the file carries those channels), are removed. A gondola or a ferry ramp is not a climb.
The score and the categories
Each climb gets a score: distance in metres multiplied by average gradient in percent. Because gradient is gain divided by distance, this is exactly 100 times the elevation gain. A climb with 240 m of gain scores 24,000, whatever its shape. That makes the score easy to reason about and easy to verify by hand.
| Category | Score | Equivalent gain |
|---|---|---|
| 4 | below 3,500 | under 35 m |
| 3 | 3,500 or more | 35-80 m |
| 2 | 8,000 or more | 80-160 m |
| 1 | 16,000 or more | 160-320 m |
| HC | 32,000 or more | 320 m and above |
Anything that passes the minimums is at least category 4, even if its score (1,000 for the minimum case) is below what a "real" fourth category would be. The scale is simple and deterministic, so the same climb always gets the same label.
How this compares with races
In professional racing there is no formula. The organisers decide the category of each climb, usually weighing length, average and maximum gradient, and where it sits in the stage: a modest ramp at the finish line, or after 200 km, may be rated higher than the same hill early in the day. "HC" (hors catégorie) literally means "beyond categorisation". A distance-times-gradient score is a rule of thumb that tends to agree with those ratings for classic mountain passes, but it will disagree about plenty of climbs, in both directions. Treat the category here as a consistent way of sorting your own ascents, not as an official rating. Our guide on gear development shows how the same climbs translate into the gears you need.
A worked example
Take a local climb: 4.0 km long, 240 m of gain. The average gradient is 240 / 4,000 = 6.0 %. The score is 4,000 × 6.0 = 24,000, which equals 100 × 240. That is above 16,000 and below 32,000, so it is a category 1. Compare it with two other shapes:
- 700 m at 8 %: score 5,600 (56 m of gain), category 3. Steep, but short.
- 8 km at 5 %: score 40,000 (400 m of gain), HC. Mild gradient, but long enough to be the hardest of the three.
Now the time. You ride the 4.0 km in 20 minutes of moving time. VAM, from the Italian velocità ascensionale media, is simply gain per hour: 240 m in one third of an hour is 720 m/h. On another day you take 19:10 and the VAM is 751 m/h. A rough rule of thumb converts VAM to power per kilo: divide it by roughly (200 + 10 × gradient in %), so 720 / 260 is about 2.8 W/kg. It ignores wind, drafting, rolling resistance and your actual mass, so use it to compare efforts, not as a measurement.
Repeated climbs and how to compare your times
If you ride the same hill every week, you want those passes grouped together. Two ascents count as the same climb when their start and their top are each within 250 m of the ones of the climb that opened the group. Comparing against that first one, rather than chaining, stops two neighbouring roads from merging into one long climb.
Detected endpoints move a few metres from one day to the next, since GPS and smoothing are never identical. In one set of 61 rides around Madrid, a 2.1 km climb was found 23 times with lengths between 2,000 and 2,170 m. So raw times are slightly unfair, and VAM, which is independent of the length detected, is the better comparison. Compare like with like:
- sort passes by VAM rather than by time when the detected length varies;
- look at the best time so far as a line over dates, not only at the last result;
- keep virtual and outdoor rides apart: a trainer climb and a real one are different efforts;
- remember wind, heat and whether you rode the climb fresh or after 100 km.
GearWatts does this grouping automatically in its climbs section, and with a power meter it also shows average power per climb, but the method works with a spreadsheet too. For the physics of the effort side, see FTP and power zones.