Problem: While combining 2 tif images using gdalbuildvrt and gdal_translate, the output tif has sub-pixel shift. (GDAL 3.1.1, released 2020/06/22)

File names:

input files: input1.tif, input2.tif
input files list: input_list.txt
output VRT file: merged_output.vrt
output TIFF file: merged_output.tif

Dropbox links to the two test input files are given below.

Code (two steps):

gdalbuildvrt -srcnodata 0 merged_output.vrt -input_file_list input_list.txt -a_srs EPSG:3413
gdal_translate -of GTiff -r lanczos --config GDAL_VRT_ENABLE_PYTHON YES -ot Byte -co COMPRESS=DEFLATE merged_output.vrt merged_output.tif

Output merged tiff zoomed in to a linear feature to better visualize the shift issue

Link to test data: input1.tif input2.tif

Can someone experienced, please share his/her understanding here. I would like to use buildvrt + gdal_translate and not gdal_merge.py due to other concerns.

  • 1
    What does the source image look like? You can experience subpixel shifts if the image alignment origins are different as the output raster can only have one cell size the others are shifted (resampled) to align Aug 28 '20 at 1:32
  • @MichaelStimson. Thanks. The two source images are of identical specifications (CRS, pixel size etc.). gdalinfo img1 Origin = (-1569023.093192894710228,176913.053114637790713) Pixel Size = (0.100625939106293,-0.100625939106293) gdalinfo img2 Origin = (-1569156.112093720585108,177044.825268297485309) Pixel Size = (0.100614373063699,-0.100614373063699) Is this an issue? Space is insufficient here to write all the info but files are available from the links. I think I've hit the wall. Please see if you have further suggestion. PDash
    – PDash
    Aug 28 '20 at 4:01
  • 2
    It's not the VRT, have a look at the same location in a GIS with input1.tif and input2.tif visible and you'll see the same misalignment - i.stack.imgur.com/BKQCi.png. That's no sub-pixel shift, they're multiple pixels different.
    – user2856
    Aug 28 '20 at 4:50
  • 1
    Please don't add additional info (i.e your gdalinfo output) in comments, put it in your question.
    – user2856
    Aug 28 '20 at 4:52
  • Thanks, @user2856. I appreciate your attention to the details. It's reassuring in some sense that VRT and translate options may not have introduced this shift (that I was getting concerned about). My issue then is may be more fundamental. The original images are taken from mounted DSLR/Aircraft and are not properly georeferenced/aligned then. The solution is to identify GCPs and again georeference them. If I have some newer findings otherwise or see a further issue with VRT/translate, I will get back here for the discussion. Cheers
    – PDash
    Aug 28 '20 at 5:24