Gps Degrees to Decimal Help
Gps Degrees to Decimal Help
Hi, there is a way to have in identify -format the lat and long in decimal format?? THX
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Gps Degrees to Decimal Help
What is your exact command line? What is your IM version and platform? Can you provide an example image? Are the lat/lon coming from the EXIF data? You can always get the data and convert using "%[fx:xxxxx]" calculations.
Re: Gps Degrees to Decimal Help
Thx, windows 10 64bit last version ImageMagik
identify -format "%[EXIF:GPSLatitude],% [EXIF:GPSLongitude]\n"
identify -format "%[EXIF:GPSLatitude],% [EXIF:GPSLongitude]\n"
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Gps Degrees to Decimal Help
That is not a valid command. You need an image. Can you post an example image so I can test and show how to convert. You cannot change the format of the lat/lon in identify, since it just reads what is in the EXIF data. It would need a special -define to be created to tell it to use fractional degrees. But you can convert afterwards with existing code commands.
What is your exact IM version.
Re: Gps Degrees to Decimal Help
Ok Thx, I explain to you step by step
ImageMagick 7.0.6 Q16 (64-bit)
Windows 10 64
cmd shell
Well my question is.. I need to calculate decimal lat lng "d + m/60 + s/3600" but the IM output is in Degrees Format, like this
First, why on the second line the order is wrong??? Deg Sec MIn and not Deg Min Sec?? Anyway can you sho me if exist a way to have directly in the output the lat,lng in Decimal format? Thx again
PS: use this links 4 the images with the exif included
https://ibb.co/cMzDDk
https://ibb.co/eZTUm5
https://ibb.co/iMdvR5
ImageMagick 7.0.6 Q16 (64-bit)
Windows 10 64
cmd shell
Well my question is.. I need to calculate decimal lat lng "d + m/60 + s/3600" but the IM output is in Degrees Format, like this
Code: Select all
identify -format "%[EXIF:GPSLatitude],%[EXIF:GPSLongitude]\n" *.jpg > log.txt
38/1, 42/1, 2485/100,9/1, 8/1, 1115/100
45/1, 5946/100, 0/1,8/1, 5697/100, 0/1
35/1, 42/1, 5079/100,139/1, 47/1, 4815/100
PS: use this links 4 the images with the exif included
https://ibb.co/cMzDDk
https://ibb.co/eZTUm5
https://ibb.co/iMdvR5
Last edited by rootx on 2017-09-14T09:18:46-07:00, edited 1 time in total.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Gps Degrees to Decimal Help
I have no devices that know their latitude and longitude, so I've never researched this, but you might find that:
- some devices record in degrees and minutes (including fractions) only
- some record in degrees, minutes and seconds (including fractions).
Thus, "45/1, 5946/100, 0/1" is 45 degrees and 59.46 minutes, and zero seconds.
A minute is 1/60 of a degree. A second is 1/60 of a minute. So you need to parse each lat or long into the six numbers, and do the arithmetic.
A lat or long is: A/B, C/D, E/F
In degrees this is: A/B + (C/D)/60 + (E/F)/3600
- some devices record in degrees and minutes (including fractions) only
- some record in degrees, minutes and seconds (including fractions).
Thus, "45/1, 5946/100, 0/1" is 45 degrees and 59.46 minutes, and zero seconds.
A minute is 1/60 of a degree. A second is 1/60 of a minute. So you need to parse each lat or long into the six numbers, and do the arithmetic.
A lat or long is: A/B, C/D, E/F
In degrees this is: A/B + (C/D)/60 + (E/F)/3600
snibgo's IM pages: im.snibgo.com
Re: Gps Degrees to Decimal Help
Thx, but, the question is, IM is able to return the decimal format directly or not?
IMG OUTPUT
38/1, 42/1, 2485/100,9/1, 8/1, 1115/100
45/1, 5946/100, 0/1,8/1, 5697/100, 0/1
35/1, 42/1, 5079/100,139/1, 47/1, 4815/100
Formula
DD = d + m/60 + s/3600
Result
38.7069027777778,-9.13643055555555
45.991,8.9495
35.7141083333333,139.796708333333
-9.13643055555555 this is because if the GPSLatitudeRef or GPSLongitudeRef is "W" OR "S".
IMG OUTPUT
38/1, 42/1, 2485/100,9/1, 8/1, 1115/100
45/1, 5946/100, 0/1,8/1, 5697/100, 0/1
35/1, 42/1, 5079/100,139/1, 47/1, 4815/100
Formula
DD = d + m/60 + s/3600
Result
38.7069027777778,-9.13643055555555
45.991,8.9495
35.7141083333333,139.796708333333
-9.13643055555555 this is because if the GPSLatitudeRef or GPSLongitudeRef is "W" OR "S".
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Gps Degrees to Decimal Help
As I say, I have no devices that know their latitude and longitude, so I can't test it, but I assume IM just spits out the EXIF data, with no arithmetic.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Gps Degrees to Decimal Help
Here is a Unix syntax shell script to compute the latitude. You can do the same for longitude
This code could be used to create your own custom identify_gps as a script. I have several such custom identify scripts that I use to report selected information.
Code: Select all
lat=`identify -format "lat=%[EXIF:GPSLatitude]\n" IMG_0448.jpg`
echo "lat=$lat"
lat=lat=38/1, 42/1, 2485/100
lat_deg1=`echo $lat | cut -d, -f1 | cut -d/ -f1`
lat_deg2=`echo $lat | cut -d, -f1 | cut -d/ -f2`
lat_min1=`echo $lat | cut -d, -f2 | cut -d/ -f1`
lat_min2=`echo $lat | cut -d, -f2 | cut -d/ -f2`
lat_sec1=`echo $lat | cut -d, -f3 | cut -d/ -f1`
lat_sec2=`echo $lat | cut -d, -f3 | cut -d/ -f2`
latitude=`convert xc: -format "%[fx:($lat_deg1/$lat_deg2) + ($lat_min1/$lat_min2)/60 + ($lat_sec1/$lat_sec2)/3600]" info:`
echo "latitude=$latitude"
latitude=38.7069
Re: Gps Degrees to Decimal Help
Are you doing anything with the images in IM or just reading the metadata? If the latter, then you might be better off with Exiftool. You'll still get DMS but the format will be consistent regardless of device and you can customise list format easily. https://sno.phy.queensu.ca/~phil/exifto ... ml#Inverse
Re: Gps Degrees to Decimal Help
Thx, I know Exiftool ..... Problem is when Exiftool try to read a folder in another languages with special char FAIL... you can try to use in your cmd filename=utf8 etc... but belive me It doesn't works!! For that reason I come here!
I know a way with a script to do it, but why IM is not able to do it directly in a line cmd?? And the result look very strange 4 me...
IMG OUTPUT
If IM change the position order evrery script need another if condition to regulate it, Exiftool 4example respect the output order.
I know a way with a script to do it, but why IM is not able to do it directly in a line cmd?? And the result look very strange 4 me...
IMG OUTPUT
Code: Select all
38/1, 42/1, 2485/100,9/1, 8/1, 1115/100
45/1, 5946/100, 0/1,8/1, 5697/100, 0/1<--------------------------- ???? The right order is DMS(d + m/60 + s/3600) and not DSM
35/1, 42/1, 5079/100,139/1, 47/1, 4815/100
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Gps Degrees to Decimal Help
Why do you say that this is in DSM order? It isn't.45/1, 5946/100, 0/1,8/1, 5697/100, 0/1<--------------------------- ???? The right order is DMS(d + m/60 + s/3600) and not DSM
IM simply prints the text that is in the EXIF GPS tag:
5946/100 minutes is 59.46 which is 59 minutes 27.6 seconds.45/1, 5946/100, 0/1,8/1, 5697/100, 0/1n
From the exif.org spec: http://www.exif.org/Exif2-2.PDF
In this case the EXIF tag, as printed by IM, is in "dd/1,mmmm/100,0/1" format. It is then up to you to convert it to whatever format you require.GPSLatitude
Indicates the latitude. The latitude is expressed as three RATIONAL values giving the degrees, minutes, and seconds, respectively. If latitude is expressed as degrees, minutes and seconds, a typical format would be dd/1,mm/1,ss/1. When degrees and minutes are used and, for example, fractions of minutes are given up to two decimal places, the format would be dd/1,mmmm/100,0/1.
BTW. Neither Exiftool nor IM find any GPS info in the third image.
Oh great. After all this I find that the OP has crossposted that the problem is solved.
https://www.imagemagick.org/discourse-s ... =3&t=32703
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.