0

I'm using a gdalbuildvrt command to build a VRT file from TIFF files (using the -separate option). It's a very time-consuming process once I have thousand of images. I would like to add more dates into this VRT file.

Is it possible or do I need to run again considering all the files?

I found no option to make it.

The commands I used were:

> gdalbuildvrt index1.vrt *.tif -separate

> gdalbuildvrt index2.vrt new_image.tif -separate

> gdalbuildvrt final_index.vrt index1.vrt index2.vrt -separate

4
  • A workaround than may work is to create a new vrt file from the added images and then combine the old.vrt and new.vrt with gdalbuildvrt.
    – user30184
    Aug 25, 2022 at 0:01
  • I've tried it, but I got a message "gdalbuildvrt does not support heterogeneous band numbers". That happens because my old.vrt has 500 bands and the new.vrt has just one (the image I want to add).
    – Julio
    Aug 25, 2022 at 2:03
  • Do you want to add the new image as a new band? Doesn't it work with -separate?
    – user30184
    Aug 25, 2022 at 17:18
  • Yes, I want to add the new image as a new band and it doesn't work with -separate option.
    – Julio
    Aug 25, 2022 at 19:27

1 Answer 1

1

This old question may have an answer Adding band to existing GeoTiff using GDAL? but if the Python solution means that the whole 500 band raster should be copied into memory first then it does not feel optimal. However, I tested a manual workaround which seemed to work.

  1. Open the VRT file with 500 bands with a text editor

  2. Create a VRT from the file that you want to add as a new band and open the new single band VRT with a text editor.

  3. Copy the VRTRasterBand section of the new VRT and place it at the bottom of the big VRT after the last band.

  4. Edit the band number of the added band into 501 in this place:

    <VRTRasterBand dataType="Byte" band="1">

  5. Now the big vrt contains 501 bands.

Because you have thousands of images the manual method does not resolve your problem but explain it to some programmer and ask them to make a script for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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