DJI Mavic, Air and Mini Drones
Friendly, Helpful & Knowledgeable Community
Join Us Now

Altitude information from exif data photos

ASL, AGL, feets, meters, AGL being not real AGL, but referring to the takeoff point, arrrrggghh, lol

A simple question of "what altitude are you at", with so many possible ways to interpret an answer,
 
"what altitude are you at", with so many possible ways to interpret an answer,
Then let's also bring QNH and QFE into play ... :)
 
  • Like
Reactions: borislip
DJI stores some of the metadata in the XMP portion of the image. Apparently, EXIFTool can find that. Here is a not-very-elegant Python 3 function that will grab the XMP metadata from an image:
Python:
def get_dji_meta( filepath ):
   """
    Returns a dict with DJI-specific metadata stored in the XMB portion of the image
    """
    
    # list of metadata tags
    djimeta=["AbsoluteAltitude","RelativeAltitude","GimbalRollDegree","GimbalYawDegree",\
         "GimbalPitchDegree","FlightRollDegree","FlightYawDegree","FlightPitchDegree"]
    
    # read file in binary format and look for XMP metadata portion
    fd = open(filepath,'rb')
    d= fd.read()
    xmp_start = d.find(b'<x:xmpmeta')
    xmp_end = d.find(b'</x:xmpmeta')

    # convert bytes to string
    xmp_b = d[xmp_start:xmp_end+12]
    xmp_str = xmp_b.decode()
    
    fd.close()
    
    # parse the XMP string to grab the values
    xmp_dict={}
    for m in djimeta:
        istart = xmp_str.find(m)
        ss=xmp_str[istart:istart+len(m)+10]
        val = float(ss.split('"')[1])
        xmp_dict.update({m : val})
        
    return xmp_dict

Here is an example:

# test the function
file = 'DJI_0012.JPG'
xmp_dict = get_dji_meta( file )
print(xmp_dict)

{'AbsoluteAltitude': -154.17, 'RelativeAltitude': 70.4, 'GimbalRollDegree': 0.0, 'GimbalYawDegree': 126.0, 'GimbalPitchDegree': -90.0, 'FlightRollDegree': 1.4, 'FlightYawDegree': 122.7, 'FlightPitchDegree': -17.6}
 
  • Like
Reactions: borislip
DJI stores some of the metadata in the XMP portion of the image...
Something I've happened to notice though - XMP data is stripped by LightRoom after exporting the jpegs. EXIF data is copied over, though.

Also... kinda makes me wonder, whats better, the MP's AGL reading (which is relative to the take-off point, which may happen to be off some skyscraper balcony), or a calculated AGL (while the sources, such as open-elevation.com may be imprecise).
 
Something I've happened to notice though - XMP data is stripped by LightRoom after exporting the jpegs. EXIF data is copied over, though.

Also... kinda makes me wonder, whats better, the MP's AGL reading (which is relative to the take-off point, which may happen to be off some skyscraper balcony), or a calculated AGL (while the sources, such as open-elevation.com may be imprecise).
For some reason, the python script you provided doesn't work for me.
I have tried with different images, that i know at which altitude above ground they were take but the script is giving wrong values.
For instance, one of the photos was at 30m above ground, the elevation value for that coordinates is 125 (according to the api.open-elevation), the ASL reported from the GPS is 40, and the AGL value reported by the script is: -84 where it should be 30m, right ?
 
Lycus Tech Mavic Air 3 Case

DJI Drone Deals

New Threads

Forum statistics

Threads
131,188
Messages
1,560,750
Members
160,156
Latest member
gplunk99