Forum

Author Topic: Geotagged Altitude Conversion from Feet to Meters  (Read 3872 times)

ktfank

  • Newbie
  • *
  • Posts: 6
    • View Profile
Geotagged Altitude Conversion from Feet to Meters
« on: August 14, 2017, 07:00:57 PM »
I have a set of geotagged photos where the altitude field is recorded in feet, but Agisoft thinks it is in meters. The photos were originally recorded in WGS 84 (EPSG: 4326) and I have converted the coordinate system to NAD83 (EPSG: 26910). How can I apply a simple conversion to the altitude field from feet to meters?

Thank you for the help!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14843
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #1 on: August 14, 2017, 07:15:18 PM »
Hello ktfank,

I can suggest to use Python script for it and apply it after loading the coordinate information. It will convert only altitude values from feet to meters:
Code: [Select]
import PhotoScan
chunk = PhotoScan.app.document.chunk
foot = 0.3048
footUS = 0.30480060960121924
for camera in chunk.cameras:
   if camera.reference.location:
      coord = camera.reference.location
      camera.reference.location = PhotoScan.Vector([coord.x, coord.y, coord.z * foot])
print("Script finished")
Best regards,
Alexey Pasumansky,
Agisoft LLC

ktfank

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #2 on: August 14, 2017, 07:31:11 PM »
Thanks, Alexey. For some reason, I get a syntax error ("invalid character in identifier) when running this code. Particularly, after foot = 0.3048. The >>> no longer appears after the command and if I try to forge ahead and put in the next line of code the syntax error occurs.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14843
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #3 on: August 14, 2017, 07:39:32 PM »
Hello ktfank,

There are three ways to run the script:

1. save the code as .py file and execute via Tools Menu -> Run script command,

2. turn on Rich Python Console in Advanced Preferences tab, then copy the full code there and press Enter a couple of times, while the cursor is in the very end of the last code line,

3. in the simple Console run the lines one by one (copy line, press Enter and etc.), in this case note that indentation is important for the contents of the for loop and if statement, so these lines should start with the corresponding number of "tabs".
Best regards,
Alexey Pasumansky,
Agisoft LLC

ktfank

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #4 on: August 14, 2017, 09:55:02 PM »
Great, it worked. Thanks!

MVidra

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #5 on: June 30, 2022, 03:37:40 PM »
Is there a way to do the opposite and convert from Meters to Feet?

Paulo

  • Hero Member
  • *****
  • Posts: 1320
    • View Profile
Re: Geotagged Altitude Conversion from Feet to Meters
« Reply #6 on: June 30, 2022, 06:13:42 PM »
Hello MVidra,

to do inverse, just divide by conversion factor instead of multiply as in:
Code: [Select]
import Metashape as PhotoScan
chunk = PhotoScan.app.document.chunk
foot = 0.3048
footUS = 0.30480060960121924
for camera in chunk.cameras:
   if camera.reference.location:
      coord = camera.reference.location
      camera.reference.location = PhotoScan.Vector([coord.x, coord.y, coord.z / foot])
print("Script finished")
Best Regards,
Paul Pelletier,
Surveyor