Creating pointmap using picture location data

I created a python script that collects the location data of pictures from a given folder. And presents them on a map in .jpg format.

For the majority of the code I used AI. It’s incredible how easy it is to create a code with its help. I barely know how to code and I can make scripts that are functioning.

So now I try to explain step by step what happened here. Usually it is hard to get the result straight out from AI. You have to break it down into smaller tasks and then put it together.

Step 1:

Let's create a jpg file filled with a colour.
Click to check Code for Step 1

Step 2:

Now let's put a dot in it.
Click to check Code for Step 2

Step 3:

Lets have multiple dots and lets arrange them like coordinates. It means we go from West to East from-180 to 180 and from south to north from -90 to 90.
Click to check Code for Step 3

Step4

In the next step we read the properties of a picture. This is an example of the raw data from a picture (the actual location data marked bold):
{256: 2304, 257: 9728, 34853: {0: b'\x02\x02\x00\x00', 1: 'S', 2: (50.0, 27.0, 57.0), 3: 'W', 4: (73.0, 2.0, 0.0), 5: b'\x00'}, 34665: 176, 271: 'HUAWEI', 272: 'POT-LX1', 305: 'Picasa', 274: 8, 306: '2021:12:02 13:32:59', 530: (2, 2), 36864: b'0220', 40961: 1, 40962: 1947, 36867: '2021:12:02 13:32:59', 36868: '2021:12:02 13:32:59', 40963: 8219, 40965: 490, 42016: 'e1ce528cbe29fcf70000000000000000', 37384: 0}

Old cables
blank jpg
Old cables
jpg with a dot
Old cables
jpg with multiple dots
Old cables
jpg with dots based on location data

This part is actually more complicated than I would have thought. We take the coordinate data and modify it to have clear numbers. Then the coordinates has to be transormed in a format which can be represented on the rectangle space. The easiest way is to use the Equirectangular projection, because in this case the coordinates will directly allign with the map. The widely used mercator projection would require more complex calculations.

picture11 description
picture11 description

Click to check Full code
To run the code, all you have to do is to:
Make a new folder.
Save the code as "filename.py"
copy in the new folder another folder containing all the pictures you wanna use.
In this folder should be the background image as well named "background.jpg"
open terminal
navigate to the folder were your script is
use this command in terminal: python3 filename.py
The script will ask for the name of the folder where the pictures are, simply type it and press enter
The script is going to generate the .jpg file into the main folder.
Tőkési Sándor, Basel, 2024.12.01.