Author Topic: Extracting GPS info from Nikon D850 NEF files  (Read 496 times)

HarryEC123

  • Newbie
  • *
  • Posts: 6
Extracting GPS info from Nikon D850 NEF files
« 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

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1079
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #1 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.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #2 on: April 22, 2019, 07:02:16 AM »
A Nikon D850 by itself doesn't store GPS position.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #3 on: April 22, 2019, 07:32:42 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #4 on: April 22, 2019, 07:36:52 AM »
Ah, thanks.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #5 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.

Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #6 on: April 22, 2019, 07:58:49 AM »
exiftool does show some stuff from the sidecar file.  For example:

Code: [Select]
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.


Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #7 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.


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #8 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.)
« Last Edit: April 22, 2019, 11:38:52 AM by Phil Harvey »
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 1079
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #9 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
Hayo Baan – Photography
Web: www.hayobaan.nl

Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #10 on: April 22, 2019, 11:04:04 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #11 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

  • ExifTool Freak
  • *****
  • Posts: 391
    • A selection of Alan Clifford's photographs
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #12 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.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #13 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

HarryEC123

  • Newbie
  • *
  • Posts: 6
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #14 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?


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #15 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

HarryEC123

  • Newbie
  • *
  • Posts: 6
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #16 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"

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14896
    • ExifTool Home Page
Re: Extracting GPS info from Nikon D850 NEF files
« Reply #17 on: April 24, 2019, 06:49:20 AM »
See the config file that I posted earlier in this thread.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).