TomTom POI export, conversion and use in other products

Joined
Mar 3, 2025
Messages
5
Country
<img src="/styles/default/custom/flags/gb.png" alt="United Kingdom" /> United Kingdom
TomTom Model(s)
Rider 450
I use multiple tools to plan multi day motorcycle routes. TomTom is good, but not in all areas. It can be difficult to get data out of tomtom to use with other tools, but thankfully tomtom allow you to download your data. While this is great, it is not very useful as is for other systems.

I wanted my tomtom data in a generic format (CSV and GPX) that I could then upload to other planners to use. I also wanted to archive the data in a format that could be used in the future.

I used a bit of AI (copilot) to create a few python programs that will take the Tomtom MyDrive data export and convert it into OV2, GPX, and CSV files.

My simple AI prompt:
Code:
I need some code written in python that will accept a JSON file as input and convert it to a OV2 file as output.
Can you write this for me? I would like to add the JSON file via STDIN.
I will run the program as using the following command "python3 json-csv.py < places.json".
Can you alter the code to accept this input and export to a file called output.cvs?

Took 10 minutes and now all my POIs (for years) are all in Google Maps, Calimoto!

Maybe this might help others?

Here's how I did it:

1) Log in to mydrive in a browser
2) Click the three lines (aka Hamburger) at the top left
3) Click "Download Your Data"
4) Choose where to save the file (default title is userData.json)

Once downloaded you will need to EDIT THE FILE (I used VSCode). The json file will have POIs AND routes. I was only interested in the POIs and wanted to export over 1000 POIs into a single file. To edit the file to work with the code do the following:

1) Open the file
2) Search for "routes", select everything from "routes" to the end of the file and DELETE it.
3) Now you have just the PLACES, but the tomtom JSON file will not work without a small change
4) Remove the following from the beginning of file:
{
"places":
5) Save file (I chose chose the filename "places.json")

Your JSON file should be something like this:
JSON:
[
  { JSON object
   with the info for
  POI1}
  { JSON object
   with the info for
  POI2}
  { JSON object
   with the info for
  POIetc}
]

Here is an actual example of a single POI
JSON:
    [
{
      "id": "73b1cb1d-ffcd-4087-9b52-d85eaba77a53",
      "createdAt": 1740155249931,
      "createdBy": "tomtom_v2-67565992",
      "createdByAppId": "TTM",
      "createdByAppVersion": "3.70.4",
      "modifiedAt": 1740155250104,
      "navCloudFavouriteID": "03ea6a0a-9714-43de-a545-95093ba5f59e",
      "type": "GENERIC",
      "mapLocation": {
        "pointLatLon": [
          51.0862,
          -0.4625
        ],
        "locationInfo": {
          "point": [
            51.0862,
            -0.4625
          ],
          "externalID": "Y7TqcCGqgN-Jt4-Fk7-JSQ",
          "provider": "TOM_TOM",
          "type": "POI",
          "customName": "Pub - The Fox Inn",
          "poiName": "The Fox Inn",
          "poiCategory": "CAFE_PUB",
          "formattedAddress": "Guildford Road, Rudgwick, Horsham, RH12 3JP",
          "street": "Guildford Road",
          "postCode": "RH12",
          "countryISO3": "GBR"
        }
      }
    }
  ]

Use the code below, copy and paste it into a text editor and save it on your computer in a folder with the JSON files.
Once saved you run the code using the following command line:

Code:
for CSV:
python3 json-csv.py < places.json
The output will be in the file called output.csv

For GPX:
python3 json-gpx.py < places.json
The output will be in the file called output.gpx

You can take the output file and load into google maps, or the route planner of your choice.

Here is the code to convert the JSON file via STD-IN in a command line on a mac, pc, or linux machine:

Python code to convers JSON to CSV - save as "json-csv.py"
Python:
import csv
import sys

def json_to_csv(input_data, csv_output_file):
    try:
        # Parse JSON data from input
        data = json.loads(input_data)

        # Open the CSV file for writing
        with open(csv_output_file, 'w', newline='', encoding='utf-8') as csvfile:
            fieldnames = ['latitude', 'longitude', 'name', 'address', 'country']
            writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

            # Write the header row
            writer.writeheader()

            # Write rows from the JSON data
            for entry in data:
                map_location = entry.get('mapLocation', {})
                location_info = map_location.get('locationInfo', {})
                point = location_info.get('point', [0, 0])  # Default to [0, 0] if missing
               
                writer.writerow({
                    'latitude': point[0],
                    'longitude': point[1],
                    'name': location_info.get('customName', 'No Name'),
                    'address': location_info.get('formattedAddress', 'No Address'),
                    'country': location_info.get('countryISO3', 'Unknown Country')
                })
       
        print(f"CSV file created: {csv_output_file}")
    except Exception as e:
        print(f"Error occurred: {e}")

if __name__ == "__main__":
    # Read JSON input from STDIN
    try:
        input_data = sys.stdin.read()
        json_to_csv(input_data, "output.csv")
    except Exception as e:
        print(f"Failed to read input: {e}")


Here is the code to convert JSON to GPX - save as "json-gpx.py"

Python:
import json
import sys
from xml.etree.ElementTree import Element, SubElement, tostring, ElementTree

def json_to_gpx(input_data, gpx_output_file):
    try:
        # Parse JSON data from input
        data = json.loads(input_data)

        # Create the root element of the GPX file
        gpx = Element('gpx', version="1.1", creator="PythonScript", xmlns="http://www.topografix.com/GPX/1/1")
       
        # Add waypoints from the JSON data
        for entry in data:
            map_location = entry.get('mapLocation', {})
            location_info = map_location.get('locationInfo', {})
            point = location_info.get('point', [0, 0])  # Default to [0, 0] if missing
           
            latitude, longitude = point[0], point[1]
            name = location_info.get('customName', 'No Name')
            description = location_info.get('formattedAddress', 'No Address')
           
            # Create a waypoint element
            wpt = SubElement(gpx, 'wpt', attrib={'lat': str(latitude), 'lon': str(longitude)})
            SubElement(wpt, 'name').text = name
            SubElement(wpt, 'desc').text = description

        # Write GPX data to the output file
        tree = ElementTree(gpx)
        tree.write(gpx_output_file, encoding='utf-8', xml_declaration=True)
       
        print(f"Output written to {gpx_output_file}")
    except Exception as e:
        print(f"Error occurred: {e}")

if __name__ == "__main__":
    # Read JSON input from STDIN
    try:
        input_data = sys.stdin.read()
        json_to_gpx(input_data, "output.gpx")
    except Exception as e:
        print(f"Failed to read input: {e}")
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Latest resources

Forum statistics

Threads
29,550
Messages
200,772
Members
68,945
Latest member
Khaled

Latest Threads

Back
Top