I am testing Savitzky-Golay filter with my MODIS dataset. Currently I am testing for 10 rasters (but later on will use my whole dataset) only just to test how should I create my script. So my initial workflow is to:
- Access my raster files
- each file I need to convert to 2D array using GDAL or GDAL Numeric
- Append all those created 2D arrays to a list
- Implement numpy.dstack() to stack my 2D arrays and hopefully I can begin some analysis.
However, I getting error in the 4th step (it says memory error) -- converting my list of 2D arrays to a stack. Could you guide me some advice how to proceed. I am just building my script so for now its not so much.
import os, sys
import gdal, numpy as np
import gdalnumeric as gd
from scipy.signal import savgol_filter
rasters = list()
ws = 'G:/Test/Raster'
for folder, subs, files in os.walk(ws):
for filename in files:
aSrc = gd.LoadFile(os.path.join(folder,filename))
rasters.append(aSrc)
stackRast = np.dstack(rasters)