Is there a good way to transfer coordinates from one image to another?

Be careful, you might be entered into the German DAU awards 2020 :wink:

Here are three quick scripts that copy (from the first selected file), show (in the logs) and paste (to all selected files) GPS coordinates. To see the currently available data in the status bar use this code: {var:glob:gpsStatusBar}.

Copy GPS

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;

    if (tab.selected_files.count == 0) return;

    var fileMeta = tab.selected_files(0).metadata;
    if (fileMeta != 'image') return;

    var lat = fileMeta.image.latitude;
    var lon = fileMeta.image.longitude;
    var alt = fileMeta.image.altitude;

    if (typeof lat != 'number') lat = 0;
    if (typeof lon != 'number') lon = 0;
    if (typeof alt != 'number') alt = 0;

    DOpus.Vars.Set('lat') = lat;
    DOpus.Vars.Set('lon') = lon;
    DOpus.Vars.Set('alt') = alt;
    DOpus.Vars.Set('gpsStatusBar') = lat.toFixed(1) + '/' + lon.toFixed(1) + '/' + alt.toFixed(1); // {var:glob:gpsStatusBar}
}

Show GPS

function OnClick(clickData) {
    var cmd = clickData.func.command;
    cmd.RunCommand('Set UTILITY=otherlog');
    DOpus.ClearOutput();

    DOpus.Output('lat: ' + DOpus.Vars.Get('lat'));
    DOpus.Output('lon: ' + DOpus.Vars.Get('lon'));
    DOpus.Output('alt: ' + DOpus.Vars.Get('alt'));
    DOpus.Output('gpsStatusBar: ' + DOpus.Vars.Get('gpsStatusBar'));
}

Paste GPS

function OnClick(clickData) {
    var cmd = clickData.func.command;
    cmd.deselect = false;

    var lat = DOpus.Vars.Get('lat');
    var lon = DOpus.Vars.Get('lon');
    var alt = DOpus.Vars.Get('alt');

    if (typeof lat != 'number') lat = 0;
    if (typeof lon != 'number') lon = 0;
    if (typeof alt != 'number') alt = 0;

    cmd.RunCommand('SetAttr META gpslatitude:' + lat + ' gpslongitude:' + lon + ' gpsaltitude:' + alt);
}

Copy GPS.dcf (1.7 KB)
Show GPS.dcf (989 Bytes)
Paste GPS.dcf (1.1 KB)

2 Likes

Thanks Jon. Most of Opus is great, of course, but i found this a bit complicated. I'm looking forward to try out the scripts below. I found, that i tend to forget stuff in Opus, i didn't use for a long time or using it on rare accasions, as it happened now.

That looks promising, already. As i have mentioned, this was a rare usecase, so i stumbled across this issue. For further cases of this kind, i think i will get along with single metadata transfers. I will give your commands a try, thanks.

Thanks too, lxp, it's good to have yet another version. I will try the new code as soon as i resume my work on old images, which i found to have missing GPS data. Since i can look up lots of reference locations, i can transfer the coordinates from those images. Your status bar code looks also very handy, i will try that right away. And yes, you are right about that, i must have been candidate for the German DAU awards several times already, i guess, which makes me a bit proud. It's always good to have plenty of room left for improvements.

:wink:

1 Like