Merge GeoTIFF files of different resolutions and utilize the higher resolution tile data where available

gdalgeotiff-tiffmergeresampling

I've got a single 1/3 arc-sec GeoTIFF file covering an area and a handful of smaller, higher resolution 1 meter GeoTIFF files that cover only some of the area that the 1/3 arc-sec file covers. I'd like to merge all the files and keep the 1 meter resolution in the merged file where it exists.

How can this be done? Do I somehow upsample the 1/3 arc-sec file first and then merge them all?

I'd prefer to use GDAL tools from the command line vs. using QGIS interactively.

Here are some details on the files I've got:

1/3 arc-sec File Information:

Extent  -78.0005555557935963,41.9994444436071035 : -76.9994444436055119,43.0005555557951880
Width   10812
Height  10812
Data type   Float32 - Thirty two bit floating point
GDAL Driver Description GTiff
GDAL Driver Metadata    GeoTIFF
Dataset Description C:/temp/geotif_source_files/00.t
Compression LZW
Band 1  
LAYER_TYPE=*
RepresentationType=*
STATISTICS_APPROXIMATE=YES
STATISTICS_MAXIMUM=743.75909423828
STATISTICS_MEAN=420.74078674426
STATISTICS_MINIMUM=135.61134338379
STATISTICS_STDDEV=143.83455577482
STATISTICS_VALID_PERCENT=100
Scale: 1
Offset: 0
More information    
AREA_OR_POINT=Area
BandDefinitionKeyword=*
DataType=*
X : 5406
Y : 5406
X : 2703
Y : 2703
X : 1351
Y : 1351
X : 675
Y : 675
X : 337
Y : 337
Dimensions  X: 10812 Y: 10812 Bands: 1
Origin  -78.0005555557935963,43.0005555557951880
Pixel Size  9.259259269220167037e-05,-9.259259269220167037e-05

Coordinate Reference System (CRS)
Name    EPSG:4269 - NAD83
Units   Geographic (uses latitude and longitude for coordinates)
Method  Lat/long (Geodetic alias)
Celestial body  Earth
Reference   Static (relies on a datum which is plate-fixed)
1-meter File Information:

Extent  319993.9999795512994751,4699994.0000448292121291 : 330005.9999795512994751,4710006.0000448292121291
Width   10012
Height  10012
Data type   Float32 - Thirty two bit floating point
GDAL Driver Description GTiff
GDAL Driver Metadata    GeoTIFF
Dataset Description C:/temp/geotif_source_files/USGS_1M_18_x32y471_NY_FingerLakes_2020_A20.tif
Compression LZW
Band 1  
STATISTICS_APPROXIMATE=YES
STATISTICS_MAXIMUM=503.98089599609
STATISTICS_MEAN=308.54269690329
STATISTICS_MINIMUM=217.19999694824
STATISTICS_STDDEV=77.859161796059
STATISTICS_VALID_PERCENT=70.89
Scale: 1
Offset: 0
More information    
AREA_OR_POINT=Area
X : 5006
Y : 5006
X : 2503
Y : 2503
X : 1252
Y : 1252
X : 626
Y : 626
X : 313
Y : 313
Dimensions  X: 10012 Y: 10012 Bands: 1
Origin  319993.9999795512994751,4710006.0000448292121291
Pixel Size  1,-1


Coordinate Reference System (CRS)
Name    EPSG:26918 - NAD83 / UTM zone 18N
Units   meters
Method  Universal Transverse Mercator (UTM)
Celestial body  Earth
Reference   Static (relies on a datum which is plate-fixed)

Best Answer

One potential solution is to use a VRT. You can create one of these with GDAL. A VRT is a virtual dataset, a sort of blueprint/instruction for an image without actually doing the processing, so no actual merging needs to be done until the data is specifically called. This allows data of different resolutions and band numbers etc to be joined with little trouble.

To build a VRT, check out the GDAL docs here: gdalbuildvrt. Pay particular attention to the description here as in your case, the order in which you build the VRT matters - latter listed files take priority. So you will want to list them in order of resolution with the coarse resolution first.

So in your case an example may be:

gdalbuildvrt -srcnodata 0 my_elev_mosaic.vrt my_100m_elev_file.tif my_50m_elev_file.tif my_5m_elev_file.tif
Related Question