Forum

Author Topic: Batch process DJI drone altitude(x) data...  (Read 2079 times)

Super_Saffer

  • Newbie
  • *
  • Posts: 36
    • View Profile
Batch process DJI drone altitude(x) data...
« on: July 17, 2021, 08:18:04 AM »
Hi all,

I need to bach process a few hundred drone images, to convert the standard DJI measurment in feet to meters. I have GCP in a LOCAL coordinate system that uses meters, and I'm having a hard time. I found this script below in an old forum post, but it no longer works. Could someone please point me in the direction of an updated version? Or would one of the moderators be so kind as to update it.

This is my first job in a while  :-[

Thank you!

Code: [Select]
#Solves EXIF altitude problem for imagery acquired by DJI drones
#For questions, get in touch with Agisoft PhotoScan forum user SAV
#Tested on PhotoScan Pro 1.4.0

import PhotoScan

doc = PhotoScan.app.document
chunk = doc.chunk

flight_height = PhotoScan.app.getFloat("Please specify the flight height in meters", 30)
take_off_alt = PhotoScan.app.getFloat("Please specify altitude above mean sea level for the point of take-off:", 0)

for camera in chunk.cameras:
if camera.reference.location:
coord = camera.reference.location
camera.reference.location = PhotoScan.Vector([coord[0], coord[1], flight_height + take_off_alt])

chunk.updateTransform()
PhotoScan.app.update()
print("DONE")

The script will first ask you for the planned flight height (it assumes that the survey occurred along a constant flight height, so no terrain following). Next, you'll have to enter the altitude above mean sea level for the point of take-off. It will then use the sum of both values to populate the altitude column in the Reference pane.

For example, if the point of take-off was 120m above mean sea level (AMSL) and the survey was planned at a constant flight height of 65m, then the altitude value would be 185m.

This script might help many DJI UAV users. Feel free to share this script/post.
« Last Edit: July 17, 2021, 08:24:47 AM by Super_Saffer »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14935
    • View Profile
Re: Batch process DJI drone altitude(x) data...
« Reply #1 on: July 18, 2021, 08:15:06 PM »
Hello Super_Saffer,

Please check, if you can use the existing script from GitHub repository, which allows to add the same fixed value to all the cameras in the Reference pane:
https://github.com/agisoft-llc/metashape-scripts/blob/master/src/add_altitude_to_reference.py
Best regards,
Alexey Pasumansky,
Agisoft LLC

Super_Saffer

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Batch process DJI drone altitude(x) data...
« Reply #2 on: July 18, 2021, 08:22:27 PM »
Thank you, Alexy!

OK this is going to be a really stupid question but.... How do I save the .PY file off of Github?

Hello Super_Saffer,

Please check, if you can use the existing script from GitHub repository, which allows to add the same fixed value to all the cameras in the Reference pane:
https://github.com/agisoft-llc/metashape-scripts/blob/master/src/add_altitude_to_reference.py

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14935
    • View Profile
Re: Batch process DJI drone altitude(x) data...
« Reply #3 on: July 19, 2021, 12:20:38 AM »
Hello Super_Saffer,

You can click on Raw button: https://raw.githubusercontent.com/agisoft-llc/metashape-scripts/master/src/add_altitude_to_reference.py

Then use Save As command in your browser to save the code as plain text file and rename its extension to .py.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Super_Saffer

  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Batch process DJI drone altitude(x) data...
« Reply #4 on: July 19, 2021, 02:23:49 AM »
Hello Super_Saffer,

You can click on Raw button: https://raw.githubusercontent.com/agisoft-llc/metashape-scripts/master/src/add_altitude_to_reference.py

Then use Save As command in your browser to save the code as plain text file and rename its extension to .py.

Thank you!