I once have used gdalbuildvrt on georeferenced images. That was okay when images did not overlap, It was also time efficient compared to gdal_merge or gdal_warp. Now I have overlapping images and gdalbuildvrt is a little problematic to me. Let me explain: For the testing purposes I have one image named 0.jpg(1600*900). I use the following command to georeference 0.jpg.
gdal_translate -a_srs EPSG:4326 -co interleave=pixel -a_ullr -180.0 90.0 180.0 -90.0 0.jpg ONE.tif
To see how it will merge overlapping areas I type the following:
gdal_translate -a_srs EPSG:4326 -co interleave=pixel -a_ullr -90.0 90.0 90.0 -90.0 0.jpg TWO.tif
So what I expect when I merge ONE.tif and TWO.tif is TWO.tif fills the center of the picture. Finally, I use gdalbuildvrt on these two:gdalbuildvrt -input_file_list LIST.txt ONETWO.vrt
, and then gdal_translate ONETWO.vrt ONETWO.tif
My LIST.txt consists of two lines: first ONE.tif then TWO.tif. The problem is here. 0.jpg was 1600*900 pixels. So I expect ONETWO.tif to be 1600*900 pixels-- ONE.tif covering from -180 to +180, and TWO.tif overwriting from -90 to +90. Although TWO.tif covers the center in the result, the final image is 2133*900 pixels. Why is this happening? Of course, I can use -outsize on gdal_translate to restore the original resolution but I am not sure if it is the right way to solve this.
On the other hand, gdal_merge is also an alternative, giving me what I want(not changing the original resolution) but it is likely that it will take longer compared to gdalbuildvrt.
I use GDAL 2.2.0, released on 2017/04/28 on OSGeo4W64. Below is an example information stored in ONETWO.vrt. It is probably this area that needs to get modified.
<VRTRasterBand dataType="Byte" band="1">
<ColorInterp>Red</ColorInterp>
<SimpleSource>
<SourceFilename relativeToVRT="1">ONE.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SourceProperties RasterXSize="1600" RasterYSize="900" DataType="Byte" BlockXSize="1600" BlockYSize="1" />
<SrcRect xOff="0" yOff="0" xSize="1600" ySize="900" />
<DstRect xOff="0" yOff="0" xSize="2133.33333333333" ySize="900" />
</SimpleSource>
<SimpleSource>
<SourceFilename relativeToVRT="1">TWO.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SourceProperties RasterXSize="1600" RasterYSize="900" DataType="Byte" BlockXSize="1600" BlockYSize="1" />
<SrcRect xOff="0" yOff="0" xSize="1600" ySize="900" />
<DstRect xOff="533.333333333333" yOff="0" xSize="1066.66666666667" ySize="900" />
</SimpleSource>
</VRTRasterBand>
Why are the destination coordinates messed up like 533.3333 or 2133.3333? And, is there a way to use gdalbuildvrt on overlapping images just like gdal_merge?