Project

General

Profile

Feature #10798

Add Reverse Geocoding (and the support for location meta data)

Added by Simon Harhues almost 2 years ago. Updated 25 days ago.

Status:
Triaged
Priority:
Low
Assignee:
-
Category:
Map / Geolocation
Target version:
-
Start date:
12/20/2015
Due date:
% Done:

20%

Affected Version:
git development version
System:
all
bitness:
64-bit
hardware architecture:
amd64/x86

Description

darktable supports GPS information for pictures. It is possible to automatically derive human readable location information from lat&long: https://en.wikipedia.org/wiki/Reverse_geocoding

Examples for services are: https://wiki.openstreetmap.org/wiki/Nominatim or https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding (API key needed)

Thus e.g. following IPTC-IIM fields could be filled automatically when GPS information is added to a picture (either during import or later on via GPX tracks or if an image is placed on the map):
  • City
  • Sublocation
  • State/Province
  • Country/Primary Location Code
  • Country

These fields should in the long run be supported by darktable through the whole process, including in the image collection module, the meta data module, the export module (as embedded meta data and as variables for the file name), the watermark module, ....

History

#1 Updated by Simon Harhues almost 2 years ago

related issues (sorry, didn't find a way how to link them directly in redmine): #10796; #9054; #9057 (maybe to consider); #9061; #9513; #9531

#2 Updated by Tobias Ellinghaus almost 2 years ago

  • % Done changed from 0 to 20
  • Status changed from New to Triaged

This has to be part of the bigger metadata overhaul.

#3 Updated by Tobias Jakobs 11 months ago

I wrote this prototype, that can be used in a Lua script to do reverse geocoding with the mapbox API, curl and jq. You need an free mapbox account to get a tokan (API key):

local function reverse_geocode()

  if not df.check_if_bin_exists("curl") then
    dt.print_error(_("curl not found"))
    return
  end    

  if not df.check_if_bin_exists("jq") then
    dt.print_error(_("jq not found"))
    return
  end    

  local sel_images = dt.gui.selection() --action_images

  local lat1 = 0;
  local lon1 = 0;
  local i = 0;

  -- Use the first image with geo information
  for _,image in ipairs(sel_images) do
    if ((image.longitude and image.latitude) and 
        (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data
       ) then
        lat1 = string.gsub(image.latitude, ",", ".");
        lon1 = string.gsub(image.longitude, ",", ".");
        break
      end
    end

    local startCommand

    local tokan = "Enter here your mapbox tokan";
    local types = "country";
    local types = "region";
    local types = "place";
    local types = "poi";

    -- MapBox documentation
    -- https://www.mapbox.com/api-documentation/#retrieve-places-near-a-location
    -- curl -s, --silent        Silent mode (don't output anything)
    -- jq could be replaced with a Lua JSON parser
    startCommand = string.format("curl --silent \"https://api.mapbox.com/geocoding/v5/mapbox.places/%s,%s.json?types=%s&access_token=%s\" | jq '.features | .[0] | '.text''", lon1, lat1, types, tokan)

    local handle = io.popen(startCommand)
    local result = handle:read("*a")
    handle:close()
    -- Errorhandling would be nice
    --dt.print_error(startCommand)

    dt.print(string.sub(result, 2, string.len(result)-2))   

    --if coroutine.yield("RUN_COMMAND", startCommand) then
    --  dt.print(_("Command failed ..."))
    --end

  --end

end

#4 Updated by Tobias Jakobs 25 days ago

Also available in: Atom PDF