1

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? – Michael Stimson May 18 '16 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 May 18 '16 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. – Michael Stimson May 18 '16 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. – Michael Stimson May 24 '16 at 22:13
0

So this was my solution:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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