Issue in reading GPS info from JPG images ?
9 views (last 30 days)
Show older comments
Ahsan Abbas on 29 Jan 2017
Commented: Walter Roberson on 22 Mar 2020
I have some JPG images that are Geo-Tagged, am trying to read Lat & Long information from them in (Deg,Min,Sec) and want to convert them in decimal degree(DD), but getting some issue, My code is as follow
info = imfinfo('DSC_0011.JPG');
The result of above statement is as follow
GPSVersionID: [2 3 0 0]
GPSLatitude: [33 34.2657 0]
GPSLongitude: [73 8.5707 0]
GPSTimeStamp: [5 5 48.6400]
As you can see from above result in both rows Lat & Long seconds are 0, but in actually when i checked the properties of corresponding image it was this:
can some one help me to resolve the issue, i am facing same error while reading different images...
Walter Roberson on 2 Feb 2017
Even if the position were represented in one double (instead of being split into degrees and minutes+fractions),
and angstrom is 10^10, so double is already capable of representing down to about 1/13th of an angstrom.
Image Analyst on 29 Jan 2017
What did you use for the second method of getting GPS info? Why not just take the fractional part and multiply by 60 to get seconds:
secs = 0.2657 * 60; % = 15.942 seconds
It will give you the same number of seconds. What's wrong with doing that, if anything?
More Answers (2)
Walter Roberson on 29 Jan 2017
Take the seconds mod 1 and multiply that by 60
joévan ziebel on 20 Mar 2020
Edited: joévan ziebel on 20 Mar 2020
I would like some help if it is possible for the function imfinfo().
I need a really good accuracy when I export my GPS coordinates from a jpg file.
More particularly on the longitude and on the latitude of the exif data.
Here is my code
filelist = dir('test/*.jpg');
nfiles = length(filelist);
fid = fopen('localisation.csv','w');
disp(['Traitement du fichier n° ',sprintf('%d',i)])
probname = filelist(i).name;
filesource = strcat('test/',probname);
f = imfinfo(filesource);
latitude = dms2degrees(latitudeTab);
longitude = dms2degrees(longitudeTab);
formatSpec = '%s,%f,%f\n';
str = sprintf(formatSpec,probname,latitude,longitude);
Don't pay attention to the entire code. The problem is only when I save the data in the f variable.
Matlab rounds the value of latitude and longitude and I don't know how to solve this. Maybe it's the imfinfo function that does this and I cannot do anything about ?
Here is the real value in the jpg file :
Here is the rounded value with matlab :
I already tried with the vpa and with a new Digits, but it seems it doesn't change something. I need the exact value, not a rounded one.
Thanks for your help in advance !
Walter Roberson on 22 Mar 2020
Besides that: the difficulty is probably in your choice of default format for displaying values. Try using
format long g
and also go into Preferences and adjust the default display format.
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!