
Visualization of the GPS data can be challenging when using programming languages. Some interesting Python packages can be used for such purposes. But, it can be hard to install and use them in some cases, especially if you have only a simple task to do. This article will show the simple but effective GPS records visualization method using Python and Open Street Maps (OSM). If you want to skip straight to the code, visit https://github.com/tisljaricleo/GPS-visualization-Python.
Before we continue, give me a second of your time. If you want to support me in my work, you can do it using this secure PayPal link. Thank you 🙂
The goal
The image below shows the goal of this method. There are three main elements that need to be included:
- Map image – map in some image format like .png, .jpg, etc.
- GPS records – records that consist of (latitude, longitude) pairs.
- Geographical coordinates – conversion from pixels to geographical coordinates.

Setup & Data
The easiest way to use code below is to install VS Code or some other IDE for editing Python code. Python Jupyter notebook users could encounter some problems or additional setup. The easiest way is to run main.py script directly from one of the IDEs.
For this article, a small GPS dataset is used collected with the Columbus V-990 logger that I’ve carried in my pocket for two days. Data is available at the github repository.
It is a simple (latitude, longitude) dataset with around 35000 records and looks like this:

Important note: To successfully run a code, data must be formatted in exact way as shown in the image above. Otherwise, the code will result in error!
Methods
Here, we will go through all the steps needed for this method to work. For the full code, visit the github repository.
1. Get the map
The map can be downloaded from https://www.openstreetmap.org/export. Just choose the part of the map that you need by clicking "Manually select a different area." Write down the coordinates of the upper left, and lower right corners in this case (45.8357, 15.9645) and (45.6806, 16.1557).

Then export it by using the "Share" button on the right side. Don’t forget to choose the option "Set custom dimensions" and align the view to the selected area.
2. Python code
Importing packages and data:
To draw geographic coordinates on the image, coordinates must be converted to image pixels. Method _scale_toimg(gps_coordinate, (image_height, image_width)) takes the GPS coordinates and converts it to image coordinates (pixels) based on the image width and height.
The image below shows the need of converting the geographic coordinates to image coordinates:

Right now, we have drawn the GPS records on the map! If you look at the image below, it will look better if there are some other elements, like grid and geographic coordinates.

Those extra elements will be added using the matplotlib package:
The final result is here:

Conclusion
Visualization of the GPS data can be challenging when using a programming language to automate it. There are some interesting Python packages that can be used for such purposes. But, in some cases, it can be hard to install and use them, especially if you have only a simple task to do.
With this article, the simple but effective method for visualization of the GPS dataset was presented. We used Python and the OSM to build a framework. In the article, all the steps were shown, but you can find the full code here: https://github.com/tisljaricleo/GPS-visualization-Python
If you have any questions or suggestions, feel free to comment or contact me!
Linkedin: https://www.linkedin.com/in/leo-tisljaric-28a56b123/
References
- Numpy https://numpy.org/
- Pandas https://pandas.pydata.org/
- Matplotlib https://matplotlib.org/
- Pillow https://pillow.readthedocs.io/en/stable/
- Open Street Maps https://www.openstreetmap.org