Results 1 to 4 of 4
  1. #1
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280

    Problem with Negative Longitude GPS Positions using WIA.ImageFile

    I am using WIA.ImageFile code to extract the GPS positions for JPG files.

    This seems to be correct for Longitudes East (i.e. Positive values), but it is also showing Longitudes West as positive values.

    The GPS coordinates as extracted using EXIF Tool appear correct, but are not correct when looking at the GPS properties using Windows 11 Files properties (which is what WIA.ImageFile picks up).

    example shown below (first image is Properties, second is data extracted using ExifTool)

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	19 
Size:	37.5 KB 
ID:	53223

    Clearly the fact that it is West is stored in the file, but this is not showing in the properties - I would have expected a negative value or W.

    Anyone have experience of this issue and how to resolve it.

    I really don't want to have to use EXIFTool in my Access code.

  2. #2
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Have solved my problem now. I read another thread that said Properties does not show the direction N/S and E/W (clearly needs fixing by Microsoft at some point).
    However, the direction can be found in Access VBA using :-
    .Properties("GpsLatitudeRef") and
    .Properties("GpsLongitudeRef"), which give N or S and E or W respectively.

    Full code I used to get Latitude and Longitude in 1/100 Seconds, plus Altitude in metres is :
    Code:
                    With CreateObject("WIA.ImageFile")
                        .LoadFile gconMyPictures & gshlFolder & "\" & strFileName
                        With .Properties("GpsLatitude").Value
                            lngLatitude = .Item(1) * 360000 + Round((.Item(2) * 6000), 0)
                        End With
                        
                        If .Properties("GpsLatitudeRef") = "S" Then
                            lngLatitude = -lngLatitude
                        End If
                        
                        With .Properties("GpsLongitude").Value
                            lngLongitude = .Item(1) * 360000 + Round((.Item(2) * 6000), 0)
                        End With
                        
                        If .Properties("GpsLongitudeRef") = "W" Then
                            lngLongitude = -lngLongitude
                        End If
                        
                       lngAltitude = .Properties("GpsAltitude").Value
                    End With

  3. #3
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,421
    Thanks for posting a solution.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Further update on this, in case anyone is trying to do the same thing. I have noticed that sometimes Seconds of Latitude and Longitude is stored in the third item and sometimes it is included in the second item along with the Minutes.
    This probably depends on the camera or phone used to take the pictures.
    Important to include the seconds, otherwise the location as shown on Google Maps will be slightly off.


    This is the code I finally used to extract the details, rounded to 1/100 seconds - later converted to Degrees, Minutes and Seconds.


    Code:
                    With CreateObject("WIA.ImageFile")
                        .LoadFile gconMyPictures & gshlFolder & "\" & strFileName
                        ' N.B. Sometimes item(2) holds seconds as well as minutes, sometimes item(3) holds the seconds.
                        With .Properties("GpsLatitude").Value
                            lngLatitude = Round(.Item(1) * 360000 + .Item(2) * 6000 + .Item(3) * 100, 0)
                        End With
                        strLatitudeRef = .Properties("GpsLatitudeRef")
                        
                        With .Properties("GpsLongitude").Value
                            lngLongitude = Round(.Item(1) * 360000 + .Item(2) * 6000 + .Item(3) * 100, 0)
                        End With
                        strLongitudeRef = .Properties("GpsLongitudeRef")
                        
                        lngAltitude = .Properties("GpsAltitude").Value
                    End With

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-30-2024, 11:16 AM
  2. Replies: 0
    Last Post: 04-29-2024, 03:59 PM
  3. Replies: 2
    Last Post: 03-03-2015, 08:43 PM
  4. latitude and longitude w Google
    By wnicole in forum Access
    Replies: 2
    Last Post: 03-26-2014, 10:58 AM
  5. How can I get latitude and longitude
    By w0st in forum Access
    Replies: 1
    Last Post: 01-05-2014, 05:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums