From the command line, execute this command inside the directory of GeoTIFF rasters you wish to stack (like a sandwich) together:
gdal_merge.py -o your_depth_stack.tif -ps x y -separate *.tif
This will stack all images inside the directory. If you only wish to stack a certain subset replace *.tif
with the desired images: image1.tif image2.tif image3.tif
etc.
x
and y
will control the spatial resolution of your output i.e. -ps 2 2
will generate 2x2 meter pixels if your data is in UTM, for example.
Other parameters (data type, output extent, etc.) can also be controlled. See the documentation https://gdal.org/programs/gdal_merge.html for more direction.