I am trying to accomplish some image stacking task in python. I am not proficient in Python and was hoping I can get some guidance to get started.

So I have large number of landsat images. Landsat images for one particular year are stored in a folder and there are sub-directories for each scene. For each scene there are numerous tif images for different VIs and I need to stack them according to their dates.I can stack images in one single folder by reading each image. But I want to automate the process as different path_rows have different number of images(one path_row might have 5 image but other one might have 10 image).

  • Do they have the same number of rows/columns and cell size? Are they exactly the same geographical area? How many bands does each have? What are you trying to achieve, you say 'stack' does that mean you want oldest (n) bands first/last then newer (n) bands? Commented May 18, 2016 at 3:17
  • Michael, They are images from same landsat path row. So they have same number of rows/colums and are same geographical area. Each image is one band. The images are named according to julian dates( the last three character in the image name is julina days). So i want the earlier dates first.
    – michelle
    Commented May 18, 2016 at 13:39
  • Related : gis.stackexchange.com/questions/80620/… look at the accepted answer; You could do this in python with GDAL but I would find it quicker to run the command, all you need do is get the file names in chronological order. Commented May 18, 2016 at 21:21
  • That's great Michelle, now use your experience (and screen shots) to answer your own question and get yourself some well deserved reputation points. Commented May 24, 2016 at 22:13

1 Answer 1


So this was my solution:

    test_vrt= ["gdalbuildvrt", "-separate", 'NDVI_test'+ ".vrt"]
    image_list =  glob.glob('*/*band1.tif')
      for myfile in image_list:
    img2tiff =["gdal_translate","test.vrt", "test_composite.tif"]

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.