Build Your Own Running Heatmap

Build an interactive map of your runs with heat, pace, hills, and heart rate.

Introduction

30 Second Summary

Your running watch remembers every outing, yet the bigger patterns can disappear inside a long activity history. The street you repeat most or the hill that pushes your heart rate highest can be hard to spot.

In this project, you will guide Claude Code to turn your running history into an interactive heatmap. You'll switch between route density, pace, hills, and heart-rate effort.

What You'll Build

Your finished map opens in the browser with your routes glowing over familiar streets and four controls for changing what the colours reveal.

By the end of this project, you'll have:

  • A point-by-point running history that turns supported GPX and FIT runs into readable GPS points with time, height, and heart rate.
  • An interactive four-layer map on OpenStreetMap with switchable Heatmap, Pace, Hills, and Heart rate views. Legends make each colour meaningful.
  • A slowest-street guess you can test against your local knowledge. You'll also compare your route coverage with Strava's paid Personal Heatmap.
  • Secret Mission: Rebuild Sam Wilson's manually written Python heat glow with 3 m pixels, blur, home detection, and treadmill filtering.

What do I need before I start?

You'll need a paid Claude plan on a supported Mac or Windows computer, plus personal running data from Strava, Garmin Connect, or Apple Health. Step 1 walks you through the Python and Claude Code setup, so no coding or terminal experience is required.

Before We Start

Before any hands-on work, commit to what you are building from your personal running history. Your goal is a private local map with four views: Heatmap, Pace, Hills, and Heart rate.

Set Up Python and Claude Code

Your map cannot exist until your computer can run Python and Claude Code from a terminal you know how to reopen.

Python runs the scripts that process your running data. Claude Code works beside you inside the project folder.

In this step, get ready to:
  • Install Python 3.15.x. Its version check reports 3.15.x.
  • Install Claude Code. Its version check prints a version number.
  • Create an empty my-running-heatmap folder. Claude Code runs inside it. Claude confirms that Python works there.
Install and verify Python

Python turns your future scripts into instructions your computer can execute. The version check confirms that your terminal can find the new installation.

macOS

  • Press Cmd+Space to open Spotlight.
  • Type Terminal into the search field.
  • Press Return to open Terminal.
  • Select the current macOS installer for Python 3.15.
  • Install the downloaded Python 3.15 package.
  • Open the downloaded installer from Downloads.
  • Follow the installer until it reports completion.

The installer finishes with Python 3.15 available on your Mac.

  • Finish the certificate setup with Install Certificates.command from /Applications/Python 3.15/.
  • Open Finder.
  • Select Applications in the sidebar.
  • Open the Python 3.15 folder.
  • Double-click Install Certificates.command.
  • Check the installed Python version by running this command:
python3 --version

What does this command do?

The python3 command selects the python.org installation on your Mac. The --version option asks it to print its version.

You should see Python 3.15.x in the output.

Windows

  • Press the Windows key to open search.
  • Type PowerShell into the search field.
  • Press Enter to open PowerShell.
  • Select the current Windows option for Python 3.15.
  • Install Python 3.15 with the Python install manager.
  • Open the downloaded installer.
  • Follow the installer until it reports completion.

The installer finishes with Python 3.15 available on your Windows PC.

  • Check the installed Python version by running this command:
python --version

What does this command do?

The python command selects your Windows Python installation. The --version option asks it to print its version.

You should see Python 3.15.x in the output.

✔️ I see the expected Python version

Python is ready. Your terminal is using version 3.15.x for this project.

ⓧ I see an older version

  • Repeat the Python 3.15 installation for your platform.
  • Close your terminal completely after installation.
  • Open a new terminal window.
  • Repeat the matching version check above.

ⓧ The command is unavailable

  • Repeat the official Python installation for your platform.
  • Close your terminal completely after installation.
  • Open a new terminal window.
  • Repeat the matching version check above.
Install and verify Claude Code

Claude Code runs as an interactive terminal session. Installing it here gives you the assistant that creates and checks the project in later steps.

macOS

  • Install Claude Code with the native macOS installer by running this command:
curl -fsSL https://claude.ai/install.sh | bash

What does this command do?

This command downloads the official Claude Code installer. It passes that installer to your shell so the setup can run.

  • Restart Terminal after the installation completes.
  • Quit Terminal completely.
  • Press Cmd+Space to open Spotlight.
  • Type Terminal into the search field.
  • Press Return to open a new Terminal window.
  • Verify the Claude Code installation by running this command:
claude --version

What does this command do?

The command asks Claude Code to print its installed version. A version number confirms that the new Terminal session can find it.

You should see a Claude Code version number.

Windows

  • Install Claude Code with the native Windows installer by running this command:
irm https://claude.ai/install.ps1 | iex

What does this command do?

This command downloads the official Claude Code PowerShell installer. It runs that installer in your current session.

  • Restart PowerShell after the installation completes.
  • Close PowerShell completely.
  • Press the Windows key to open search.
  • Type PowerShell into the search field.
  • Press Enter to open a new PowerShell window.
  • Verify the Claude Code installation by running this command:
claude --version

What does this command do?

The command asks Claude Code to print its installed version. A version number confirms that the new PowerShell session can find it.

You should see a Claude Code version number.

✔️ I see a Claude Code version

Claude Code is installed. Your new terminal session can run it.

ⓧ The command is unavailable

  • Close your terminal completely.
  • Open a new Terminal or PowerShell window.
  • Repeat the matching Claude Code version check above.
  • Use the Claude Code setup guide if the command remains unavailable.

Claude Code still unavailable?

A newly installed terminal command may only appear after every old terminal window is closed. Restart the terminal before repeating the version check.

Help me troubleshoot my Claude Code installation. You can also use the Claude Code setup guide.

Create the project and check Python

Claude Code uses the terminal's current folder as its workspace. Starting it inside my-running-heatmap keeps every future project file in one place.

macOS

  • Move to your Desktop by running this command:
cd ~/Desktop

What does this command do?

The cd command changes the current folder. The ~ symbol represents your home folder.

  • Create the project folder by running these commands:
mkdir my-running-heatmap
cd my-running-heatmap

What do these commands do?

  • The mkdir command creates the empty my-running-heatmap folder.
  • The cd command moves your terminal into that folder.

Your Terminal prompt should now show my-running-heatmap as the current folder.

  • Start Claude Code inside the project folder by running this command:
claude

What does this command do?

The command starts an interactive Claude Code session. The session uses my-running-heatmap as its workspace.

Claude presents sign-in prompts for your account.

Sign-in is the only credential step here. Keep your password inside the account sign-in flow.

  • Follow the sign-in prompts with your paid Claude account.

Before you ask Claude, do you expect it to find the same Python version that Terminal found?

  • Ask Claude to check Python by pasting this exact message:
Check that Python works here and tell me which version I have.

What does this prompt do?

The prompt asks Claude to test Python inside the current project folder. Claude proposes the platform command before it runs anything.

Claude should ask for permission to run a version command with python3.

  • Approve the Python version command.

Claude should report Python 3.15.x. It should confirm that Python works inside my-running-heatmap.

Windows

  • Move to your Desktop by running this command:
cd ~/Desktop

What does this command do?

The cd command changes the current folder. The ~ symbol represents your home folder.

  • Create the project folder by running these commands:
mkdir my-running-heatmap
cd my-running-heatmap

What do these commands do?

  • The mkdir command creates the empty my-running-heatmap folder.
  • The cd command moves your PowerShell session into that folder.

Your PowerShell prompt should now show my-running-heatmap as the current folder.

  • Start Claude Code inside the project folder by running this command:
claude

What does this command do?

The command starts an interactive Claude Code session. The session uses my-running-heatmap as its workspace.

Claude presents sign-in prompts for your account.

Sign-in is the only credential step here. Keep your password inside the account sign-in flow.

  • Follow the sign-in prompts with your paid Claude account.

Before you ask Claude, do you expect it to find the same Python version that PowerShell found?

  • Ask Claude to check Python by pasting this exact message:
Check that Python works here and tell me which version I have.

What does this prompt do?

The prompt asks Claude to test Python inside the current project folder. Claude proposes the platform command before it runs anything.

Claude should ask for permission to run a version command with python.

  • Approve the Python version command.

Claude should report Python 3.15.x. It should confirm that Python works inside my-running-heatmap.

Your local workspace is ready. Next up, you will place a known practice run inside it and request your personal running-data export.

Collect a Practice Run and Your Export

Python and Claude Code are ready inside your empty my-running-heatmap folder. Your next goal is to bring in one known run before you work with personal data.

A known practice file gives you a fast validation target while a personal export may take hours to arrive.

In this step, get ready to:
  • Download the known practice FIT activity into runs. The folder contains exactly one .fit file.
  • Request or locate a personal running-data export. It stays outside runs.
  • Identify any supported GPX, FIT, or compressed FIT files. Leave .tcx and .tcx.gz files outside the project.
Download the known practice run

Personal exports vary by service. The known FIT activity gives every learner the same file for the first checkpoint.

  • In Claude Code from earlier, download the practice activity by pasting this exact request:
Download https://raw.githubusercontent.com/dtcooper/python-fitparse/master/tests/files/activity-small-fenix2-run.fit into the runs folder.

What does this prompt do?

The prompt gives Claude Code the source URL. It also names runs as the destination folder.

The filename stays activity-small-fenix2-run.fit. That exact name makes the sample easy to distinguish from your personal activities.

  • Approve each request that matches the folder creation, network access, or file save described in your prompt.

You should see activity-small-fenix2-run.fit saved inside runs. Your project now has a known activity for repeatable checks.

Practice file not downloading?

  • Open the raw practice file in your browser.
  • Save the file with the exact name activity-small-fenix2-run.fit.

You should see the downloaded FIT file on your computer.

  • Move activity-small-fenix2-run.fit into my-running-heatmap/runs.

The runs folder should contain the sample file. Help me troubleshoot downloading and placing this FIT file.

Request your personal running export

Your personal history turns the finished map into a record of places you actually run. Choose the source that holds your activity data.

Strava

  • In Strava, open Settings.
  • Select My Account.
  • Select Get Started under Download your account.
  • Select Request download.

The download email may take a few hours to arrive. That delay is expected, so you can keep the sample file as your working data in the meantime.

Garmin Connect

You should finish with a downloaded group of activity files that you can inspect before copying supported formats.

Apple Health

  • Export all Apple Health data from the Health app on your iPhone.
  • Open the Health app on your iPhone.
  • Select Summary.
  • Tap your picture or initials.
  • Tap Export All Health Data.
  • Choose a sharing method.

You should receive an export that you can unzip outside runs. Its workout-routes/ folder may contain GPX route files.

Separate the sample from personal files

The sample count only stays trustworthy while runs contains the known activity alone. Inspect your personal export somewhere else before adding anything to the project.

  • Leave your personal export outside my-running-heatmap/runs.
  • Unzip the personal export in its current location when it arrives.
  • In Finder on macOS or File Explorer on Windows, find the downloaded export archive.
  • Use the archive extraction option to unpack it beside the original file.

You should see the export's files or folders beside the downloaded archive. Strava exports may include activities.csv plus an activities/ folder.

  • Locate any files ending in .gpx, .fit, or .fit.gz.
  • Leave files ending in .tcx or .tcx.gz outside runs.

You should now know which personal files this project supports. If your export is still pending, the sample file is enough for the next step.

Before you ask Claude, how many .fit files do you expect it to report?

  • Confirm the sample checkpoint by pasting this exact message into Claude Code:
Count the files in runs by type.

What does this prompt do?

Claude Code inspects the filenames inside runs. It groups the result by file extension without changing your files.

  • Approve read-only folder inspection if Claude Code asks for permission.

That is your clean checkpoint. Claude reports one .fit file because activity-small-fenix2-run.fit is the only file inside runs.

Your sample checkpoint is ready while your personal export waits safely outside runs. Next, you will turn supported activity files into one consistent point table.

Turn Runs into a Point Table

Your known FIT activity has proved that the sample file is ready inside runs.

Mixed activity formats must become one consistent table of GPS points before Claude Code can build a reliable map.

In this step, get ready to:
  • Install gpxpy 1.6.2, fitdecode 0.11.0, and Folium 1.0.0. Finish with read_runs.py ready to parse supported running files.
  • Run the sample file through the parser. Finish with points.csv containing 2,809 point rows, including 2,808 with heart-rate values.
  • Add your supported personal files to runs. Finish with an updated point table and clear skip messages for unsupported activities.
Build the run parser

The parser gives GPX and FIT activities the same structure. Each row in the resulting CSV represents one recorded GPS point.

It also reports files that cannot contribute usable points. Those messages keep one incompatible activity from hiding the results of every valid run.

  • Paste this exact message into Claude Code:
Install gpxpy, fitdecode and folium. Then write read_runs.py. It reads every .gpx, .fit and .fit.gz file in runs, and saves every GPS point to points.csv with the run name, time, latitude, longitude, height and heart rate (blank if missing). Skip .tcx files and files with no GPS, and print what it skipped. At the end print how many runs and points it read.

What does this prompt do?

  • The package request gives the parser readers for GPX and FIT activities.
  • The file request normalizes every usable point into the same six columns.
  • The reporting request makes skipped activities visible in the terminal.
  • Confirm that Claude proposes gpxpy version 1.6.2.
  • Confirm that Claude proposes fitdecode version 0.11.0.
  • Confirm that Claude proposes Folium version 1.0.0.
  • Confirm that the proposed package command uses python3 on Mac or python on Windows.
  • Approve the package installation after every version matches.
  • Approve the creation of read_runs.py.

You should see read_runs.py inside my-running-heatmap once Claude finishes.

Package installation going off track?

Decline the installation if Claude proposes fitparse or Sam's pinned requirements.txt. Ask Claude to use the three versions listed above.

If the installation still fails, help me diagnose the package command for this project.

Validate the sample point table

The known sample gives you fixed totals before personal exports introduce variation. Matching that checkpoint proves the parser can read a valid FIT activity.

Before you run the parser, do you expect the sample to produce a point table without being skipped?

  • Ask Claude to run the parser by pasting this exact message:
Run read_runs.py.

What does this prompt do?

Claude selects the Python command for your platform. The script reads the sample from runs before writing its normalized points to points.csv.

  • Approve the matching platform command after comparing it with the command below.

macOS

  • Match Claude's proposed command to this exact Mac command:
python3 read_runs.py

What does this command do?

The python3 command runs read_runs.py with the Python installation you verified earlier.

Windows

  • Match Claude's proposed command to this exact Windows command:
python read_runs.py

What does this command do?

The python command runs read_runs.py with the Python installation you verified earlier.

That baseline is working. Claude should report 1 run with 2,809 points, including 2,808 points with heart rate.

A point row becomes useful when you can connect its columns to one recorded moment. Claude can inspect the generated table without changing it.

  • Ask Claude to inspect one row by pasting this exact message:
Open points.csv and explain what one row means.

What does this prompt do?

Claude reads points.csv and connects one row's run name, timestamp, coordinates, height, and optional heart rate to a single recorded point.

You should see an explanation covering the run, time, latitude, longitude, height, and heart_rate columns.

✔️ Awesome, I've got everything!

Your parser matches the sample checkpoint. The point table is ready for personal running files.

ⓧ I'd like to double check the full code

Compare your read_runs.py with this complete file.

import csv
import gzip
from pathlib import Path

import fitdecode
import gpxpy

RUNS_DIR = Path("runs")
OUTPUT_FILE = Path("points.csv")
FIELDNAMES = [
    "run",
    "time",
    "latitude",
    "longitude",
    "height",
    "heart_rate",
]


def run_name(path):
    name = path.name
    if name.lower().endswith(".fit.gz"):
        return name[:-7]
    return path.stem


def clean_time(value):
    if value is None:
        return ""
    if hasattr(value, "isoformat"):
        return value.isoformat()
    return str(value)


def gpx_heart_rate(point):
    for extension in point.extensions:
        for node in extension.iter():
            tag = node.tag.split("}")[-1].lower()
            if tag in {"hr", "heartrate", "heart_rate"} and node.text:
                try:
                    return float(node.text)
                except ValueError:
                    return None
    return None


def read_gpx(path):
    rows = []
    with path.open("r", encoding="utf-8") as source:
        document = gpxpy.parse(source)

    for track in document.tracks:
        for segment in track.segments:
            for point in segment.points:
                rows.append(
                    {
                        "run": run_name(path),
                        "time": clean_time(point.time),
                        "latitude": point.latitude,
                        "longitude": point.longitude,
                        "height": "" if point.elevation is None else point.elevation,
                        "heart_rate": "" if gpx_heart_rate(point) is None else gpx_heart_rate(point),
                    }
                )
    return rows


def read_fit(path):
    rows = []
    opener = gzip.open if path.name.lower().endswith(".fit.gz") else open

    with opener(path, "rb") as source:
        with fitdecode.FitReader(source) as fit_file:
            for frame in fit_file:
                if frame.frame_type != fitdecode.FIT_FRAME_DATA:
                    continue
                if frame.name != "record":
                    continue

                latitude = frame.get_value("position_lat", fallback=None)
                longitude = frame.get_value("position_long", fallback=None)
                if latitude is None or longitude is None:
                    continue

                height = frame.get_value("enhanced_altitude", fallback=None)
                if height is None:
                    height = frame.get_value("altitude", fallback=None)

                rows.append(
                    {
                        "run": run_name(path),
                        "time": clean_time(frame.get_value("timestamp", fallback=None)),
                        "latitude": latitude,
                        "longitude": longitude,
                        "height": "" if height is None else height,
                        "heart_rate": frame.get_value("heart_rate", fallback=""),
                    }
                )
    return rows


def main():
    RUNS_DIR.mkdir(exist_ok=True)
    all_rows = []
    run_count = 0

    for path in sorted(RUNS_DIR.iterdir()):
        if not path.is_file():
            continue

        lower_name = path.name.lower()
        try:
            if lower_name.endswith(".tcx") or lower_name.endswith(".tcx.gz"):
                print(f"Skipped {path.name}: TCX is not supported in this project.")
                continue
            if lower_name.endswith(".gpx"):
                rows = read_gpx(path)
            elif lower_name.endswith(".fit") or lower_name.endswith(".fit.gz"):
                rows = read_fit(path)
            else:
                continue
        except Exception as error:
            print(f"Skipped {path.name}: {error}")
            continue

        if not rows:
            print(f"Skipped {path.name}: no GPS points.")
            continue

        all_rows.extend(rows)
        run_count += 1

    with OUTPUT_FILE.open("w", newline="", encoding="utf-8") as destination:
        writer = csv.DictWriter(destination, fieldnames=FIELDNAMES)
        writer.writeheader()
        writer.writerows(all_rows)

    heart_rate_points = sum(row["heart_rate"] not in {"", None} for row in all_rows)
    print(f"Read {run_count} runs and {len(all_rows):,} points.")
    print(f"Heart rate: {heart_rate_points:,} points.")
    print(f"Saved {OUTPUT_FILE}.")


if __name__ == "__main__":
    main()

How is the file organised?

The first section defines the input folder, output file, and column names. The helper functions normalize names, timestamps, GPX points, and FIT records.

The main() function chooses a reader for each supported file. It writes the combined rows before printing the checkpoint totals.

Add your personal runs

The sample established a fixed baseline. Your own files now test the parser against the mix of formats produced by your running-data source.

  • Copy your supported .gpx, .fit, and .fit.gz activity files into my-running-heatmap/runs.

macOS

  • Switch back to the Finder window containing your unzipped personal export.
  • Select the supported activity files.
  • Press Cmd+C to copy them.
  • Return to my-running-heatmap in Finder.
  • Open the existing runs folder.
  • Press Cmd+V to paste the files.

Windows

  • Switch back to the File Explorer window containing your unzipped personal export.
  • Select the supported activity files.
  • Press Ctrl+C to copy them.
  • Return to my-running-heatmap in File Explorer.
  • Open the existing runs folder.
  • Press Ctrl+V to paste the files.

Before you rebuild the table, do you expect every file in runs to add GPS rows?

  • Rebuild the table by pasting this exact message into Claude Code:
Run read_runs.py.

What happens on this run?

The script rereads every supported activity in runs. It replaces points.csv with one cumulative table.

TCX activities and files without GPS produce skip messages when they are present. The remaining activities still contribute their usable points.

  • Approve the same platform-specific Python command you matched during the sample check.

You should see updated run, point, and heart-rate totals that reflect your supported files. Any TCX activity or file without GPS should appear in a printed skip message.

Your totals can now exceed the sample checkpoint. That increase confirms your personal runs have joined the same point table.

Your running history is now a map-ready point table. Next, you will turn those coordinates into your first interactive Heatmap layer.

Build the First Heatmap

Your run data is now consistent, but rows in points.csv cannot show the routes captured by your GPS points.

In this step, you will guide Claude Code to turn those points into a local heatmap. Folium will place it on OpenStreetMap inside heatmap.html.

In this step, get ready to:
  • Create make_map.py with Claude Code. It reads points.csv and saves a centred heatmap.html.
  • Run the map script. Its terminal confirmation names the Heatmap layer.
  • Open the local map. It displays OpenStreetMap with one visible overlay named Heatmap.
Ask Claude to create the first map

A Folium map turns rows of coordinates into an interactive HTML file. The HeatMap plugin gives repeated locations a stronger glow.

  • Paste this exact message into the Claude Code session from earlier:
Write make_map.py. It reads points.csv and makes heatmap.html with folium: a HeatMap layer of every point, centred on my runs.

What does this prompt do?

  • It tells Claude to create make_map.py inside your existing project.
  • It names points.csv as the source of the map coordinates.
  • It requests one visible layer named Heatmap inside heatmap.html.
  • Approve the creation of make_map.py when Claude asks.
  • Use the Claude Code permission prompt to allow the file edit.
  • Approve the platform-specific Python command if Claude asks to run the new file.
  • Use the next Claude Code permission prompt to allow the command once.

If Claude runs the script, you should see confirmation that heatmap.html was saved.

  • Compare Claude's make_map.py with the complete first-map version below.

✔️ Awesome, I've got everything!

Your first map generator is ready for a direct terminal test.

ⓧ I'd like to double check the full code

Your make_map.py file should match this cumulative version.

import csv
import math
from collections import defaultdict
from datetime import datetime

import folium
from folium.plugins import HeatMap

INPUT_FILE = "points.csv"
OUTPUT_FILE = "heatmap.html"
LAYER_NAMES = ["Heatmap"]


def optional_float(value):
    if value in {None, ""}:
        return None
    return float(value)


def optional_time(value):
    if not value:
        return None
    try:
        return datetime.fromisoformat(value.replace("Z", "+00:00"))
    except ValueError:
        return None


def load_points():
    runs = defaultdict(list)
    with open(INPUT_FILE, newline="", encoding="utf-8") as source:
        for row in csv.DictReader(source):
            runs[row["run"]].append(
                {
                    "time": optional_time(row["time"]),
                    "lat": float(row["latitude"]),
                    "lon": float(row["longitude"]),
                    "height": optional_float(row["height"]),
                    "heart_rate": optional_float(row["heart_rate"]),
                }
            )
    return runs


def main():
    runs = load_points()
    all_points = [point for points in runs.values() for point in points]
    if not all_points:
        raise SystemExit("points.csv has no GPS points. Run read_runs.py first.")

    centre = [
        sum(point["lat"] for point in all_points) / len(all_points),
        sum(point["lon"] for point in all_points) / len(all_points),
    ]
    map_object = folium.Map(location=centre, zoom_start=13, control_scale=True)

    HeatMap(
        [[point["lat"], point["lon"]] for point in all_points],
        name="Heatmap",
        radius=12,
        blur=16,
        gradient={0.2: "#ffeda0", 0.5: "#feb24c", 0.8: "#f03b20", 1.0: "#bd0026"},
        show=True,
    ).add_to(map_object)

    map_object.fit_bounds(
        [
            [min(point["lat"] for point in all_points), min(point["lon"] for point in all_points)],
            [max(point["lat"] for point in all_points), max(point["lon"] for point in all_points)],
        ]
    )
    folium.LayerControl(collapsed=False).add_to(map_object)
    map_object.save(OUTPUT_FILE)

    print(f"Saved {OUTPUT_FILE} with layers: {', '.join(LAYER_NAMES)}")


if __name__ == "__main__":
    main()
Run the map script from a second terminal

A second terminal lets Claude Code remain open while you rebuild the map yourself. This gives you a repeatable command for every later change.

  • Open a second Terminal window on Mac or PowerShell window on Windows beside Claude Code.
  • Press Cmd+Space on macOS or the Windows key on Windows to open the search bar.
  • Type Terminal on macOS or PowerShell on Windows. Press Enter.

macOS

  • Move into my-running-heatmap by running this command:
cd my-running-heatmap

What does this command do?

The cd command moves the terminal into your existing my-running-heatmap folder.

Windows

  • Move into my-running-heatmap by running this command:
cd my-running-heatmap

What does this command do?

The cd command moves PowerShell into your existing my-running-heatmap folder.

Before you run the script, which file do you expect it to create from points.csv?

macOS

  • Build the map by running this command:
python3 make_map.py

What does this command do?

The command runs make_map.py with Python. The script reads points.csv before saving the map as heatmap.html.

You should see Saved heatmap.html with layers: Heatmap.

Windows

  • Build the map by running this command:
python make_map.py

What does this command do?

The command runs make_map.py with Python. The script reads points.csv before saving the map as heatmap.html.

You should see Saved heatmap.html with layers: Heatmap.

Map script not completing?

Confirm that points.csv is inside my-running-heatmap. Check that the file contains point rows below its header.

If the terminal cannot find the project folder, return to the folder that contains my-running-heatmap before running the navigation command again.

Help me diagnose why make_map.py cannot generate heatmap.html.

Open and inspect the map

The generated HTML file contains the interactive map. OpenStreetMap tiles load when the file opens, so the map needs an internet connection even though heatmap.html stays on your computer.

Before you open the result, do you think one density layer can explain pace, elevation, and heart rate?

macOS

  • Open the generated map in your default browser by running this command:
open heatmap.html

What does this command do?

The open command asks macOS to open heatmap.html with its default browser.

Windows

  • Open the generated map in your default browser by running this command:
start heatmap.html

What does this command do?

The start command asks Windows to open heatmap.html with its default browser.

Your browser should open an OpenStreetMap map centred on the GPS points in points.csv.

You have your first running map working. Your point table now has a visual form that you can pan and zoom.

  • Drag the map to pan across your routes.
  • Use the map's zoom controls to inspect dense sections.
  • Display Heatmap from the layer switcher.
  • Find the layer switcher in the top-right corner of the map.
  • Select Heatmap to keep that overlay visible.

You should see the visible overlay named exactly Heatmap.

The glow reveals where your recorded points cluster. The map cannot identify your slowest street, climbing direction, or heart-rate effort.

That shortfall is intentional. You have proved that density provides one useful view of a run while leaving important questions unanswered.

Your first heatmap is visible. Next up, you will turn the same GPS points into separate views for pace, hills, and heart rate.

Add Pace, Hills, and Heart Rate

Your first heatmap turns your GPS points into a map you can explore. You can now see where your running routes overlap.

The basic heatmap hides speed, terrain, and effort.

In this step, Claude Code will turn the same points into three additional views. Each view answers a different question about your runs.

In this step, get ready to:
  • Add Pace and Hills layers with legends. The terminal prints a slowest-street guess.
  • Add a Heart rate layer. Runs without heart-rate data are counted as skipped.
  • Rebuild the local map. Its switcher shows Heatmap, Pace, Hills, and Heart rate.
Add Pace and Hills after a prediction

Pace uses timestamps to calculate minutes per kilometre between recorded points. Hills uses smoothed height values to calculate the gradient of each stretch.

Before you ask Claude, which street or path do you expect to appear as your slowest stretch?

  • Switch back to the Claude Code session running inside my-running-heatmap.
  • Add the Pace and Hills layers by pasting this exact request:
Add two layers to make_map.py, with a layer switcher. Pace: colour each stretch between two points by minutes per km, blue for fast and red for slow, and drop stops where I was standing still. Hills: colour each stretch by its gradient, green for downhill and purple for uphill, and smooth the heights first so GPS noise doesn't show as hills. Add a legend for each.

What does this request do?

  • The Pace layer compares timestamps with distance. Very short movements and stretches slower than the standing-stop limit are excluded.
  • The Hills layer calculates percent gradient from distance and height change. Smoothing keeps small GPS height errors from becoming false hills.
  • The layer switcher keeps each view separate. The legends explain what the colours mean.
  • Approve Claude's edit to make_map.py.
  • Approve Claude's request to run make_map.py.

You should see a printed Slowest-street guess with nearby coordinates and pace. You should also see confirmation that Heatmap, Pace, and Hills were saved.

  • Return to the browser tab showing heatmap.html.
  • Refresh heatmap.html.
  • Press Cmd+R on macOS or Ctrl+R on Windows.

You should see a layer switcher with Heatmap, Pace, and Hills.

  • Select Pace.
  • Use the layer switcher in the top-right corner of the map.

You should see blue stretches for faster movement. Slower stretches should move towards red.

  • Compare the reddest pace stretch with your prediction.
  • Select Hills.
  • Use the same layer switcher in the top-right corner.

You should see downhill stretches in green. Uphill stretches should move towards purple.

Pace or Hills layer looks empty?

Pace needs timestamps in points.csv. Hills needs height values.

Ask Claude to inspect a few rows from the affected columns. Keep smoothing enabled if the Hills layer looks noisy.

Help me diagnose an empty Pace or Hills layer.

Add Heart rate as a separate change

Heart-rate data can vary between running sources. A separate layer can use the runs that include it while reporting how many runs were skipped.

  • Return to the Claude Code session from the previous change.
  • Add the Heart rate layer by pasting this exact request:
Add a Heart rate layer: colour each stretch by heart rate, light for low and dark red for high, with a legend in bpm. Skip runs with no heart rate and print how many were skipped.

What does this request do?

  • The Heart rate layer averages the available readings across each stretch.
  • The colour scale moves from light tones for lower readings to dark red for higher readings.
  • Runs without any heart-rate readings are left out of this layer. The other layers can still use them.
  • Approve Claude's edit to make_map.py.
  • Approve Claude's request to run make_map.py.

You should see Skipped N runs with no heart rate. You should also see confirmation that all four layers were saved.

Use the reference below to confirm that Claude's final make_map.py matches the project version.

✔️ Awesome, I've got everything!

Great work. Make sure make_map.py is saved before rebuilding the map.

ⓧ I'd like to double check the full code

import csv
import math
from collections import defaultdict
from datetime import datetime

import folium
from folium.plugins import HeatMap

INPUT_FILE = "points.csv"
OUTPUT_FILE = "heatmap.html"
LAYER_NAMES = ["Heatmap", "Pace", "Hills", "Heart rate"]


def optional_float(value):
    if value in {None, ""}:
        return None
    return float(value)


def optional_time(value):
    if not value:
        return None
    try:
        return datetime.fromisoformat(value.replace("Z", "+00:00"))
    except ValueError:
        return None


def load_points():
    runs = defaultdict(list)
    with open(INPUT_FILE, newline="", encoding="utf-8") as source:
        for row in csv.DictReader(source):
            runs[row["run"]].append(
                {
                    "time": optional_time(row["time"]),
                    "lat": float(row["latitude"]),
                    "lon": float(row["longitude"]),
                    "height": optional_float(row["height"]),
                    "heart_rate": optional_float(row["heart_rate"]),
                }
            )
    return runs


def distance_m(first, second):
    radius = 6_371_000
    lat1 = math.radians(first["lat"])
    lat2 = math.radians(second["lat"])
    delta_lat = lat2 - lat1
    delta_lon = math.radians(second["lon"] - first["lon"])
    value = (
        math.sin(delta_lat / 2) ** 2
        + math.cos(lat1) * math.cos(lat2) * math.sin(delta_lon / 2) ** 2
    )
    return radius * 2 * math.asin(math.sqrt(value))


def blend(start, end, amount):
    amount = max(0.0, min(1.0, amount))
    start_rgb = tuple(int(start[index:index + 2], 16) for index in (1, 3, 5))
    end_rgb = tuple(int(end[index:index + 2], 16) for index in (1, 3, 5))
    mixed = tuple(round(a + (b - a) * amount) for a, b in zip(start_rgb, end_rgb))
    return "#{:02x}{:02x}{:02x}".format(*mixed)


def scaled(value, low, high):
    if high <= low:
        return 0.5
    return (value - low) / (high - low)


def smooth_heights(points, window=7):
    radius = window // 2
    smoothed = []
    for index in range(len(points)):
        values = [
            points[position]["height"]
            for position in range(max(0, index - radius), min(len(points), index + radius + 1))
            if points[position]["height"] is not None
        ]
        smoothed.append(sum(values) / len(values) if values else None)
    return smoothed


def pace_segments(runs):
    segments = []
    for run, points in runs.items():
        for first, second in zip(points, points[1:]):
            if first["time"] is None or second["time"] is None:
                continue
            metres = distance_m(first, second)
            seconds = (second["time"] - first["time"]).total_seconds()
            if metres < 2 or seconds <= 0:
                continue
            pace = (seconds / 60) / (metres / 1000)
            if pace > 30:
                continue
            segments.append((run, first, second, pace))
    return segments


def hill_segments(runs):
    segments = []
    for run, points in runs.items():
        heights = smooth_heights(points)
        for index, (first, second) in enumerate(zip(points, points[1:])):
            if heights[index] is None or heights[index + 1] is None:
                continue
            metres = distance_m(first, second)
            if metres < 5:
                continue
            grade = 100 * (heights[index + 1] - heights[index]) / metres
            segments.append((run, first, second, grade))
    return segments


def heart_rate_segments(runs):
    segments = []
    skipped_runs = 0
    for run, points in runs.items():
        if not any(point["heart_rate"] is not None for point in points):
            skipped_runs += 1
            continue
        for first, second in zip(points, points[1:]):
            values = [
                value
                for value in (first["heart_rate"], second["heart_rate"])
                if value is not None
            ]
            if not values:
                continue
            segments.append((run, first, second, sum(values) / len(values)))
    return segments, skipped_runs


def add_legend(map_object, pace_range, hill_range, heart_rate_range):
    legend = f"""
    <div style="position:fixed;bottom:20px;left:20px;z-index:9999;background:white;
                padding:12px;border:1px solid #777;border-radius:6px;font:13px sans-serif;">
      <div><strong>Pace</strong>: blue {pace_range[0]:.1f} to red {pace_range[1]:.1f} min/km</div>
      <div><strong>Hills</strong>: green downhill, purple uphill ({hill_range[0]:.1f}% to {hill_range[1]:.1f}%)</div>
      <div><strong>Heart rate</strong>: light {heart_rate_range[0]:.0f} to dark red {heart_rate_range[1]:.0f} bpm</div>
    </div>
    """
    map_object.get_root().html.add_child(folium.Element(legend))


def main():
    runs = load_points()
    all_points = [point for points in runs.values() for point in points]
    if not all_points:
        raise SystemExit("points.csv has no GPS points. Run read_runs.py first.")

    centre = [
        sum(point["lat"] for point in all_points) / len(all_points),
        sum(point["lon"] for point in all_points) / len(all_points),
    ]
    map_object = folium.Map(location=centre, zoom_start=13, control_scale=True)

    HeatMap(
        [[point["lat"], point["lon"]] for point in all_points],
        name="Heatmap",
        radius=12,
        blur=16,
        gradient={0.2: "#ffeda0", 0.5: "#feb24c", 0.8: "#f03b20", 1.0: "#bd0026"},
        show=True,
    ).add_to(map_object)

    pace_data = pace_segments(runs)
    pace_values = [segment[3] for segment in pace_data] or [0.0]
    pace_low, pace_high = min(pace_values), max(pace_values)
    pace_layer = folium.FeatureGroup(name="Pace", show=False)
    for run, first, second, pace in pace_data:
        folium.PolyLine(
            [(first["lat"], first["lon"]), (second["lat"], second["lon"])],
            color=blend("#2166ac", "#b2182b", scaled(pace, pace_low, pace_high)),
            weight=4,
            opacity=0.85,
            tooltip=f"{run}: {pace:.1f} min/km",
        ).add_to(pace_layer)
    pace_layer.add_to(map_object)

    hill_data = hill_segments(runs)
    hill_values = [segment[3] for segment in hill_data] or [0.0]
    hill_low, hill_high = min(hill_values), max(hill_values)
    hills_layer = folium.FeatureGroup(name="Hills", show=False)
    for run, first, second, grade in hill_data:
        if grade < 0:
            colour = blend("#b7e4c7", "#1b7837", min(abs(grade) / 12, 1))
        else:
            colour = blend("#e7d4f5", "#762a83", min(grade / 12, 1))
        folium.PolyLine(
            [(first["lat"], first["lon"]), (second["lat"], second["lon"])],
            color=colour,
            weight=4,
            opacity=0.85,
            tooltip=f"{run}: {grade:.1f}%",
        ).add_to(hills_layer)
    hills_layer.add_to(map_object)

    heart_data, skipped_runs = heart_rate_segments(runs)
    heart_values = [segment[3] for segment in heart_data] or [0.0]
    heart_low, heart_high = min(heart_values), max(heart_values)
    heart_layer = folium.FeatureGroup(name="Heart rate", show=False)
    for run, first, second, heart_rate in heart_data:
        folium.PolyLine(
            [(first["lat"], first["lon"]), (second["lat"], second["lon"])],
            color=blend("#fee5d9", "#99000d", scaled(heart_rate, heart_low, heart_high)),
            weight=4,
            opacity=0.85,
            tooltip=f"{run}: {heart_rate:.0f} bpm",
        ).add_to(heart_layer)
    heart_layer.add_to(map_object)

    map_object.fit_bounds(
        [
            [min(point["lat"] for point in all_points), min(point["lon"] for point in all_points)],
            [max(point["lat"] for point in all_points), max(point["lon"] for point in all_points)],
        ]
    )
    folium.LayerControl(collapsed=False).add_to(map_object)
    add_legend(
        map_object,
        (pace_low, pace_high),
        (hill_low, hill_high),
        (heart_low, heart_high),
    )
    map_object.save(OUTPUT_FILE)

    if pace_data:
        slowest = max(pace_data, key=lambda segment: segment[3])
        midpoint_lat = (slowest[1]["lat"] + slowest[2]["lat"]) / 2
        midpoint_lon = (slowest[1]["lon"] + slowest[2]["lon"]) / 2
        print(
            f"Slowest-street guess: near {midpoint_lat:.5f}, {midpoint_lon:.5f} "
            f"at {slowest[3]:.1f} min/km."
        )
    else:
        print("Slowest-street guess: unavailable because no timed moving segments were found.")

    print(f"Skipped {skipped_runs} runs with no heart rate.")
    print(f"Saved {OUTPUT_FILE} with layers: {', '.join(LAYER_NAMES)}")


if __name__ == "__main__":
    main()

Before you rebuild the map, which runs do you expect the heart-rate check to skip?

macOS

  • Rebuild the map. Open the result by running these commands:
python3 make_map.py
open heatmap.html

What do these commands do?

The first command rebuilds heatmap.html from your current point table. The second command opens the rebuilt file in your default browser.

Windows

  • Rebuild the map. Open the result by running these commands:
python make_map.py
start heatmap.html

What do these commands do?

The first command rebuilds heatmap.html from your current point table. The second command opens the rebuilt file in your default browser.

The terminal should print a slowest-street guess. It should also print the heart-rate skip count and confirm the four saved layer names.

  • Select Heatmap.
  • Use the layer switcher in the top-right corner.

You should see the density glow from your original map.

  • Select Pace.
  • Use the layer switcher in the top-right corner.

You should see coloured route stretches with a pace legend in min/km.

  • Select Hills.
  • Use the layer switcher in the top-right corner.

You should see coloured route stretches with a hill legend in percent grade.

  • Select Heart rate.
  • Use the layer switcher in the top-right corner.

You should see light-to-dark-red route stretches with a heart-rate legend in bpm.

One of the final layers is empty?

An empty Pace layer usually points to missing timestamps. An empty Hills layer usually points to missing height values.

An empty Heart rate layer can mean that your running source did not include heart-rate readings. The terminal skip count confirms how many runs were excluded.

Help me diagnose an empty final map layer.

Compare your map with Strava

A comparison with Strava shows what your local map adds to a standard personal density view. Your Pace, Hills, and Heart rate layers make the same route coverage easier to interpret.

  • Sign in if Strava asks for your account.
  • Return to the Personal Heatmap page after signing in.
  • Display your Personal Heatmap for running.
  • Set a date range that closely matches the runs in points.csv.

Before you compare the maps, which routes do you expect both views to emphasise?

  • Capture the Strava map at a zoom level that protects your home location.
  • Capture heatmap.html at a similar zoom level.
  • Place the two screenshots side by side.

Compare route coverage and bright areas. Check for privacy-hidden sections in Strava.

Then switch through Pace, Hills, and Heart rate in your local map. These extra views reveal speed, terrain, and effort beyond route density.

How does this compare with Sam's project?

Sam Wilson built his original running heatmap manually in Python. His project combines frequency, pace, heart-rate, and gradient views in one local HTML file.

You guided Claude through the same problem space. Your result shows that you can define the data rules and verify the output without writing the project by hand.

Secret mission

Rebuild Sam's Manual Glow

Rebuild the main Heatmap as a raster-style glow inspired by Sam Wilson's manually written Python project. Your map will gain 3 m grid cells, blur, home detection, treadmill filtering, a dark base layer, and an OpenStreetMap fallback.

Clean Up Your Resources

Clean Up Your Resources

Your map files stay on your computer. They have no ongoing hosting cost.

The choices below let you keep the project ready, archive it for later, or remove it.

Cost warning

Your paid Claude plan continues to renew at $20 per month when billed monthly. The cleanup options below affect only your local files.

Deleting my-running-heatmap does not change or cancel your subscription.

Resources you used:

  • Local project folder: my-running-heatmap.
  • Copied running data: runs, the practice file, and any supported personal activity files.
  • Project files: read_runs.py, make_map.py, points.csv, and heatmap.html.

Keep everything running

The project can remain in its current location if you want to keep adding runs. Local files remain idle until you use them again.

  • Keep the my-running-heatmap folder in its current location.
  • Add new supported activity files to runs whenever you want to update the map.
  • Use Claude Code to rerun read_runs.py after adding runs.
  • Use Claude Code to rerun make_map.py after rebuilding points.csv.

Pause - I'll come back to this later

An archive keeps the scripts and copied runs together until you are ready to continue.

  • End the active Claude Code session.
  • Create a ZIP archive of my-running-heatmap through Finder on macOS or File Explorer on Windows.
  • Store the ZIP archive in a private local backup location.
  • Keep your original source-service export outside the project folder.

Delete - I don't want to use this again

Deleting this folder is permanent, but it affects only the local copies inside my-running-heatmap. Your source-service data and Claude subscription remain unchanged.

macOS

  • End the active Claude Code session.
  • Use Finder to locate the my-running-heatmap folder where you created it.
  • Delete only the my-running-heatmap folder from its containing location.
  • Confirm that my-running-heatmap is no longer listed in that location.

Windows

  • End the active Claude Code session.
  • Use File Explorer to locate the my-running-heatmap folder where you created it.
  • Delete only the my-running-heatmap folder from its containing location.
  • Confirm that my-running-heatmap is no longer listed in that location.

Protect Your Route Privacy

Your points.csv, heatmap.html, and map screenshots can reveal your home or routine locations.

  • Review every map and screenshot before sharing it.
  • Keep route files private when they expose sensitive locations.

Nice Work!

Nice Work!

You did it! You guided Claude Code through a complete Python mapping workflow. Your running history now opens as an interactive map with four ways to understand each route.

What you learned:

  • Converted mixed running files in GPX, FIT, and compressed FIT formats into a consistent table of GPS points in points.csv. The sample check proved the parser produced 2,809 points, including 2,808 with heart rate.
  • Built a local four-layer running map with Folium and OpenStreetMap. The switcher reveals Heatmap, Pace, Hills, and Heart rate overlays with readable legends.
  • Used a side-by-side map comparison to evaluate your result against Strava's paid Personal Heatmap. You can now explain how pace, hills, and heart rate add context to route density.
  • Secret Mission: Rebuilt Sam Wilson's raster glow with 3 m grid cells plus blur. You also added home detection, treadmill filtering, a dark base layer, and an OpenStreetMap fallback. The adapted make_map.py keeps his MIT licence notice.

Ready to quiz yourself?