ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: HarryEC123 on April 22, 2019, 06:43:17 AM

Title: Extracting GPS info from Nikon D850 NEF files
Post by: HarryEC123 on April 22, 2019, 06:43:17 AM
I am trying to extract the GPS location information from Nikon D850 NEF files. The GPS information was written to the NEF file by ViewNX-i (version 1.3.0), and appears to be correct.
The only GPS tag that I can extract is GPSVersionID which has the value "2 3 0 0".

I am extracting the information in R using the package "exifr", which is using version 11.22 of ExifTool, which is running under Windows 8.1 (64 bits). From the documentation, the package calls ExifTool with the arguments -n -j -q. The package requires Perl, and I am using version 5.26.3 of ActivePerl
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Hayo Baan on April 22, 2019, 06:56:45 AM
Can you run exiftool -a -G0:1 on the file and show us the output? That way we can verify whether or not there is any gps data in the file. From there we can figure out what can be done to get the GPS info where/how you want it.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 22, 2019, 07:02:16 AM
A Nikon D850 by itself doesn't store GPS position.

- Phil
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 07:32:42 AM
Quote from: Phil Harvey on April 22, 2019, 07:02:16 AM
A Nikon D850 by itself doesn't store GPS position.

- Phil

Phil, he said that he used the Nikon view nx-i to write the gps data.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 22, 2019, 07:36:52 AM
Ah, thanks.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 07:46:58 AM
Nikonviewnx-i does not write to the photo, it writes to a sidecar file under the ./NKSC_PARAM/ directory.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 07:58:49 AM
exiftool does show some stuff from the sidecar file.  For example:

Appname                         : ViewNX-i
GPS Version ID                  : AgMAAA==
GPS Version ID Type             : Binary
GPS Latitude Ref Type           : Long
GPS Latitude                    : AAAAAAAAREAAAAAAAIBJQAAAAGDpizdA
GPS Latitude Type               : Double
GPS Longitude Ref Type          : Long
GPS Longitude                   : AAAAAAAALEAAAAAAAAAuQAAAAICFyE1A
GPS Longitude Type              : Double
GPS Map Datum                   : WGS-84
GPS Map Datum Type              : Ascii


Phil, if it is of any use, the sidecar file is attached, from a D7000, with location data inserted using nikonviewnxi by dropping a pin on the map.

Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 08:04:45 AM
@HarryEC123

If you convert the nef to a jpg with viewnx-i, you will be able to extract the location data from the .jpg.

Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 22, 2019, 09:01:30 AM
Thanks Alan,

Wow, that is odd.  Storing the values as base64-encoded binary doubles.  Weird.  Anyway, I have included a config file that will allow you to read these values directly from the viewnx sidecar file.  The only trick is that you must ignore the Composite GPSLatitudeRef/GPSLongitudeRef tags, and use the XMP-ast versions instead.

- Phil

Edit: Tweaked config file (by pretending that the tags are in the GPS instead of XMP group) to work with the existing Composite tags.  (So you don't have to ignore the Composite reference direction tags, and the signed coordinates are now available.)
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Hayo Baan on April 22, 2019, 09:05:50 AM
Interesting, the coordinates and e.g. ID are all in BASE64 encoding, for the coordinates we then need to find out how they are saved, but from the data it looks like they are stored as (a number of) (64 bit?) doubles, what coordinates did you specify? That way it should be easier to see how they are stored.

Update: I see Phil already provided a config file to help here. So is looks like the coordinates are 40°51'23.5465297698875, 14°15'59.5665740966815. Does that seem correct (it's in Naples)?

Cheers,
Hayo
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 11:04:04 AM
Quote from: Hayo Baan on April 22, 2019, 09:05:50 AM
(it's in Naples)?

Cheers,
Hayo

Yes.  Although it's only a copy in a temp directory, I put it in more or less the correct location.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 22, 2019, 11:11:22 AM
It would be good to know if I got the reference directions correct.  I didn't have samples from the western or southern hemispheres, so I had to guess at the numerical values for these.

- Phil
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Alan Clifford on April 22, 2019, 12:52:49 PM
I've marked a photo as being in Grytviken with nikonviewnxi.  Sidecar file attached.  Also attached is a small jpg created by nikonviewnxi that contains the location data.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 22, 2019, 01:05:45 PM
Alan,

Thanks!  I guessed right.  South is 1, and West is 3.

However, the Composite tags aren't picking this up properly because the "numerical" values are different than EXIF GPS.

- Phil
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: HarryEC123 on April 23, 2019, 01:41:04 PM
Converting the NEF file to a JPG enabled the following GPS fields to be extracted
GPSVersionID
GPSLatitudeRef
GPSLongitudeRef
GPSAltitudeRef
GPSMapDatum
GPSAltitude
GPSLatitude
GPSLongitude
GPSPosition

So whilst a work around, it is rather a slow process to convert a large number of files.
Would an example NEF file help with known GPS parameters?

Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 23, 2019, 09:41:00 PM
As Alan said, the GPS is not in the NEF, so a sample won't help.

- Phll
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: HarryEC123 on April 24, 2019, 04:24:03 AM
Enclosed is an example nksc file where the GPS information is stored.
ExifTool can read the file, and identifies the fields correctly, but not the formatting. For example, GPSPosition returns
"AAAAAACAQ0AAAAAAAIBDQAAAAKC/i0xA AAAAAAAAM0AAAAAAAABHQAAAAOBHYDtA"
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 24, 2019, 06:49:20 AM
See the config file that I posted earlier in this thread.

- Phil
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: aroach on April 30, 2022, 01:46:43 AM
Having experienced this problem as well, and faced with the prospect of having to fix several hundred files by hand, I wrote a small open source windows CLI program (https://github.com/a-roach/nkscgeosync (https://github.com/a-roach/nkscgeosync)) to automate the process. As a bonus, the program also lets you set various noise reduction settings en-mass.
Title: Re: Extracting GPS info from Nikon D850 NEF files
Post by: Phil Harvey on April 30, 2022, 06:44:04 AM
Note that the current version of ExifTool does decode GPS from NKSC files.  The config file is no longer necessary.

- Phil