Request for Comments: Reverse Geocoding in Darktable with Lua/Python

Dear all,
as I have some free time at my hands - badly injured my elbow when mountainbiking, recovery is a matter of another 6 weeks minimum - I decided to scratch a personal itch:

I very often track my movements with a GPS logger ,and during rawfile import, I write those coordinates into the raw file by means of exiftool. Now coordinates are nice and allow to see the image location on a map, but I want to see the postal-like address in the metadata of the image.

The openstreetmap-Nominatim servers allow reverse geocoding without all the privacy implications of google maps at al., and there is a very nice python module to query nominatim with a pair of coordinates and get back address data.

What I have accomplished so far is a lua post-import (or keyboard shortcut) triggered script that calls a python script to request the address data and return it in a lightroom style hierarchical location tag like “where|Italy|Emilia-Romagna|Bologna|Malpighi”. This tag then gets added to the darktable image.

My question to you is: Is this something that’s interesting for other people, too?

If yes I would put it on GitHub and invest some time to make it more configurable in terms of language and tag prefix.

—Markus

1 Like

Yes! I had a pure lua implementation that @wpferguson gave me some time ago, but it stopped working recently.

@paperdigits was that the GeoToolboxNg code or something else?

Yes, geotoolboxng.

The code is here: github.com/springm/darktable-reverse-geocode
As this is my first use of github, please bear with eventual mistakes.

Excellent, thanks for sharing. It might be nice to have this all in lua :slight_smile:

@springm Nominatim’s usage policy is limited to 1 request per second. Does the python script take that into account?

@wpferguson: no, this limit is no yet obeyed.

The script currently uses the rate-limiting facilities of the geopy library, but as the script gets started anew on each run of the lua loop, the limiting does not take place.

I think of adding a timestamp to the python script parameters, which then could be used to make python wait until one second has passed.
Bad idea. I have to find a (portable) way how the script can detect when it was run last. The problem is, that the lua script gets triggered separately for each image during import, but runs in a loop on all marked images when called via shortcut. The loop is easier to slow down.

Another feature I am considering is making the language configurable, in which the adresses get retrieved from Nominatim

BTW - in my opinion, Discourse doesn’t handle the <del> tag very well; looks more like a highlight. Personally, I use ~~ to strikethrough the text — if that was what you wanted.

@afre you are right, I will edit it accordingly

@springm - Here is the geoToolbox_ng.lua that @paperdigits was talking about. It’s a pure lua solution. It also gives you a choice of reverse geocoding engines.
geoToolbox_ng.zip (12.2 KB)

Thank you, Bill. I will have a look.
If my memory serves me right, years ago you were active in the Corel Aftershot forum?