0

I have ~100 jpeg images taken by a Drone. I tried to use gdal_merge to merge them and create a big tile GeoTIFF image. gdal_merge spends lots of time, and in the end, it just put each jpeg image precisely on top of the previous one. The GeoTIFF result shows the last jpeg file.

I tried to diagnose the problem and used gdalinfo. I found the jpeg files include full GPS EXIF data, but they do not have proper corner coordinates. That means the corner coordinate of all jpeg images shows like below:

Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 3648.0)
Upper Right ( 4864.0,    0.0)
Lower Right ( 4864.0, 3648.0)
Center      ( 2432.0, 1824.0)

Is there any way to use GDAL to extract Corner Coordinates based on GPS coordination in the jpg’s EXIF file?

I know OpenDroneMap uses the GDAL and perfectly merges Drone images. I just don’t know how it extracts Corner Coordinates from EXIF? Below link is an example (images are in the images folder):

https://github.com/OpenDroneMap/odm_data_aukerman


Per @Spacedman ask, here is the full extract from gdalinfo. The sample image is here: https://github.com/OpenDroneMap/odm_data_aukerman/blob/master/images/DSC00229.JPG

OpenDroneMap can perfectly merge the images in the sample meantioned above. However, gdal_merge fails since it cannot figure out Corner Coordinates (my guess)

Driver: JPEG/JPEG JFIF
Files: 0.JPG
Size is 4896, 3672
Coordinate System is `'
Metadata:
  EXIF_BrightnessValue=(7.53672)
  EXIF_ColorSpace=1
  EXIF_ComponentsConfiguration=0x01 0x02 0x03 0x00
  EXIF_CompressedBitsPerPixel=(3)
  EXIF_Contrast=0
  EXIF_CustomRendered=0
  EXIF_DateTime=2016:06:29 10:47:04
  EXIF_DateTimeDigitized=2016:06:29 10:47:04
  EXIF_DateTimeOriginal=2016:06:29 10:47:04
  EXIF_DigitalZoomRatio=(1)
  EXIF_ExifVersion=0230
  EXIF_ExposureBiasValue=(0)
  EXIF_ExposureMode=0
  EXIF_ExposureProgram=2
  EXIF_ExposureTime=(0.004)
  EXIF_FileSource=0x03
  EXIF_Flash=16
  EXIF_FlashpixVersion=0100
  EXIF_FNumber=(3.3)
  EXIF_FocalLength=(4.45)
  EXIF_GPSAltitude=(346.315)
  EXIF_GPSLatitude=(41) (18) (13.7576)
  EXIF_GPSLatitudeRef=N
  EXIF_GPSLongitude=(81) (45) (1.6792)
  EXIF_GPSLongitudeRef=W
  EXIF_ImageDescription=                               
  EXIF_Interoperability_Index=R98
  EXIF_Interoperability_Version=0x30 0x31 0x30 0x30
  EXIF_ISOSpeedRatings=100
  EXIF_LensSpecification=(4.45) (44.5) (3.3) (5.9)
  EXIF_LightSource=0
  EXIF_Make=SONY
  EXIF_MakerNote=SONY DSC 
  EXIF_MaxApertureValue=(3.44531)
  EXIF_MeteringMode=5
  EXIF_Model=DSC-WX220
  EXIF_PixelXDimension=4896
  EXIF_PixelYDimension=3672
  EXIF_RecommendedExposureIndex=100
  EXIF_ResolutionUnit=2
  EXIF_Saturation=0
  EXIF_SceneCaptureType=0
  EXIF_SceneType=0x01
  EXIF_SensitivityType=2
  EXIF_Sharpness=0
  EXIF_Software=eBee
  EXIF_UserComment=
  EXIF_WhiteBalance=0
  EXIF_XResolution=(350)
  EXIF_YCbCrPositioning=2
  EXIF_YResolution=(350)
Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 3672.0)
Upper Right ( 4896.0,    0.0)
Lower Right ( 4896.0, 3672.0)
Center      ( 2448.0, 1836.0)
Band 1 Block=4896x1 Type=Byte, ColorInterp=Red
  Overviews: 2448x1836, 1224x918, 612x459, 160x120
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 2 Block=4896x1 Type=Byte, ColorInterp=Green
  Overviews: 2448x1836, 1224x918, 612x459, 160x120
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 3 Block=4896x1 Type=Byte, ColorInterp=Blue
  Overviews: 2448x1836, 1224x918, 612x459, 160x120
  Image Structure Metadata:
    COMPRESSION=JPEG

@RoVo should note that this has to be part of a batch process. I cannot use QGIS or interactive tools.


I am aware of so many commercial tools and products that can do this.

I am asking if I can use GDAL to solve this problem.

  • What GPS data do you have in the EXIF metadata? Just the drone location is not enough, you also need the direction and field of view of the camera. – Spacedman Jan 16 at 8:33
  • ... and the altitude aboved ground. – pLumo Jan 16 at 8:39
  • The corner coordinates are simply the pixel size of the jpeg and not georeferenced data. You need to calculate that using the above mentioned information. It's more or less simple trigonometry. – pLumo Jan 16 at 8:40
  • 3
    Possible duplicate of Drone aerial imagery to QGIS – pLumo Jan 16 at 8:42
  • @RoVo, please see my Update 2 and 3 – Allan Xu Jan 16 at 8:50
1

No, you can't use GDAL to do this because it is beyond the scope of GDAL.

You can use GDAL to read in the file, you can then use some mathematical expressions to work out the corner coordinates from the metadata, and then you can use GDAL to write a georeferenced file out.

You can use any programming language that supports the GDAL API to do this - C++, Python being the most popular.

  • Thank you for help. Do you know any Python sample code to do this by any chance? – Allan Xu Jan 16 at 9:08
  • 1
    That's a new question - try doing the research first and then asking it as a new question. – Spacedman Jan 16 at 9:58
  • New Question but check pypi.org/project/ExifRead first – Mapperz Jan 16 at 15:39
  • @Mapperz, EXIF data is easy to read, but convering it to Corner Coordinates is a rocket science unfortunately. – Allan Xu Jan 16 at 15:52
  • fme does this > knowledge.safe.com/questions/4427/… – Mapperz Jan 16 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.