Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:11:23+00:00 2026-06-10T05:11:23+00:00

I am trying to convert the Exif longitude and latitude data into a Google

  • 0

I am trying to convert the Exif longitude and latitude data into a Google friendly decimal value. I have read a lot of tutorials, but nothing seems to be working for me. I may well be doing this completely wrong.

I successfully get the Exif data as follows:

$exif_data = exif_read_data($path . ‘/user/images/4.jpg’);

$egeoLong = $exif_data['GPSLongitude'];
$egeoLat = $exif_data['GPSLatitude'];
$egeoLongR = $exif_data['GPSLongitudeRef'];
$egeoLatR = $exif_data['GPSLatitudeRef'];

From there I end up with the following array for the values:

deg Long: 118/1
min Long: 2147/100
sec Long: 0/1
Longitude Ref: W

deg Lat: 34/1
min Lat: 433/100
sec Lat: 0/1
Latitude Ref: N

And I run them through this function to obtain a decimal value (I got this function here on Stackoverflow).

$geoLong = gpsDecimal($egeoLong[0], $egeoLong[1], $egeoLong[2], $egeoLongR);
$geoLat = gpsDecimal($egeoLat[0], $egeoLat[1], $egeoLat[2], $egeoLatR);

function gpsDecimal($deg, $min, $sec, $hemi) {
    $d = $deg+((($min*60)+($sec))/3600);
    return ($hemi=='S' || $hemi=='W') ? $d*=-1 : $d;
}

Which returns the following… that puts the coordinates in the middle of the ocean… not where I took the photo.

Latitude: 41.216666666667
Longitude: -153.78333333333

Can anyone tell me what I am doing wrong, or a better way to achieve this. Any help is much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:11:25+00:00Added an answer on June 10, 2026 at 5:11 am

    I found that same formula, and it didn’t work for me either. What I finally figured out, and what worked for me, was:

    function toDecimal($deg, $min, $sec, $hem) 
    {
        $d = $deg + ((($min/60) + ($sec/3600))/100);
        return ($hem=='S' || $hem=='W') ? $d*=-1 : $d;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file and I'm trying convert it into a (table( HTML
I'm trying convert all special chars into HTML safe entities on their way into
Trying to convert a string of binary inputs into a vector of ints. I'd
Trying to convert this c code into MIPS and run it in SPIM. int
im trying to convert a date format into a new format in this example
Trying to convert super(B, self).method() into a simple nice bubble() call. Did it ,
hi i am trying to convert &#x0A into &#x0D&#x0A in select query SELECT TOP
I'm trying to convert a .jar application into an applet. I've unpacked the .jar
I'm using lambda expression and trying convert into uint while adding into the Hashset.
Trying to convert a perl script to php. In perl I have a hash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.