1
\$\begingroup\$

I have a large amount of photos that I need to apply gps-coordinates to. I also have a list of the objects that have been photographed, each with an unique ID and with known x/y-coordinates. Is it possible to apply tags to the photograph individually (the unique ID) and then to apply the gps-coordinates en bloc from the list to the entire collection?

Cheers,

Edit: I've made a CSV file with ID,X,Y values, an example of which is copied in below. What I was hoping to do was to add a tag manually and individually to each photo in my folder (this would be the Axxx in the below list) and then transfer the x/y coordinates to the photo itself - later allowing me to add the photos as a layer of precisely placed dots in the QGis software. If that is possible in a relatively simple way.

The thread Saaru has linked to points in the right direction, but preferably I woudn't have to change the title of the photo, but just add a tag. I haven't had the opportunity to try ExifTool yet, as I am working on a work PC that doesn't allow the installation of "unknown" software. I'll see if I can get time to try on my own pc this evening...

enter image description here

Btw the photos in question are just simple jpg.'s.

\$\endgroup\$
8
  • \$\begingroup\$ Does this answer your question? How can I geotag images with location data in a CSV file? \$\endgroup\$ Commented Nov 21, 2022 at 12:26
  • 1
    \$\begingroup\$ If this doesn't answer your question, could you please edit your question to include what previous questions or possible solutions you've looked at and why they were not helpful? That makes it easier for answerers to suggest a solution that works for you, instead of suggesting things you might have tried and do not work for some reason. \$\endgroup\$ Commented Nov 21, 2022 at 12:28
  • \$\begingroup\$ There's also photo.stackexchange.com/questions/56301/… \$\endgroup\$
    – Tetsujin
    Commented Nov 21, 2022 at 12:54
  • \$\begingroup\$ If the first column is filename (or tag) how you will deal with duplicates? Lines 14, 15 for example? \$\endgroup\$ Commented Nov 21, 2022 at 14:14
  • 1
    \$\begingroup\$ @MortenL.Jensen As Romeo Ninov said, you're gonna have to convert your coordinates. I'm pretty sure you'll want to convert to WGS84 (EPSG:4326). \$\endgroup\$ Commented Nov 21, 2022 at 16:15

1 Answer 1

2
\$\begingroup\$

It seems your main problem is:

How can I show photos on a map in QGIS?

You have the following at your disposal:

  • A set of photos
  • A lookup table with IPTC keywords and their corresponding coordinates (in the EPSG:25832 coordinate system)

This can be divided into the following sub-problems:

  1. Identify which keyword(s) a photo has
  2. If one of the keywords of the photo matches one in the lookup table:
    • Lookup the coordinates that corresponds with that tag
    • Reproject the EPSG:25832 coordinates to WGS84 (EPSG:4326) latitude and longitude coordinates
    • Convert the lat/lon coordinates to a format suitable for the EXIF GPS tag
    • Write the EXIF GPS tag of the photo
  3. Read in the photo into a QGIS map

The stackexchange network is not a coding service, so I cannot provide you with ready to go scripts, but I have suggestions on how to solve the sub-problems.

1. Identify which keyword(s) a photo has

2a. Lookup the coordinates that corresponds with that tag

This can be done in a myriad of ways, but I am familiar with Python where you can e.g. use a dictionary to store your lookup table:

lookup = {
    'A4166': [546043.0552, 6189132.4628],
    'A4165': [546031.2343, 6189128.3107],
    etc...
}

Alternatively you could use a pandas DataFrame:

import pandas as pd
lookup = pd.read_csv('/path/to/file.csv')
coords = lookup.loc[lookup.ID == 'A4166']

2b. Reproject the EPSG:25832 coordinates to WSG84

Again, many ways, but in Python I would use geopandas to do any kind of reprojecting of coordinates. Assuming you would have used a Dataframe in the previous step:

import geopandas as gpd
gdf = gpd.GeoDataFrame(lookup, geometry=gpd.points_from_xy(lookup.X, lookup.Y)
# Let geopandas know that the data is in EPSG:25832
gdf.set_crs(epsg=25832)
# Reproject it to 
gdf.to_crs(epsg=4326, inplace=True)

Now you have a lookup table in the variable gdf with the coordinates in the WGS84 coordinate system.

2c. Convert the lat/lon coordinates to a format suitable for the EXIF GPS tag

The ExifTool documentation describes how the GPS tags look. You will have to create some conditions based on the coordinate sign on when to write N or S in the GPSLatitudeRef and E or W in the GPSLongitudeRef fields.

2d. Write the EXIF GPS tag of the photo

The same libraries from step 2a can be used to write to the appropriate fields.

3. Read in the photo into a QGIS map

This tutorial was the first hit on Google when I looked for "place photos in QGIS". Roughly the steps are:

  1. Import Geotagged Photos via Processing Toolbar > Vector Creation > Import Geotagged Photos
  2. View photos in popup: set the HTML Map Tip in the Display property of the layer to: <img src="file:///[% photo %]" width="350" height="250">

If you run into any issues with solving one of the sub-problems you are very welcome to edit your question (or post a new one) showing what you've tried and where you get stuck.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.