I get a series of NDVI rasters every 2 weeks and need to calculate changes. The rasters overlap, but are different in area. The resolution is also a little different in each raster,
raster 1: -0.34533, 0.34533
raster 2: -0.35001, 0.35001
This can change slightly with every raster.
I am trying to automate the process with python, GDAL. the rasters are between 1gb-20gb in size.
I think i am almost there, but when i try to change the pixel size of the rasters to match, there seems to be a shift, which messes up the calcs.
If i can get the pixel sizes to match, i should then be able to calc the differences.
here is the code for adjusting the pixel size:
WorkingFolder = 'C:/Users/me/Desktop/NDVI/Testing/' for f in os.listdir(WorkingFolder): print (f) fName, fExt = os.path.splitext(f) if fExt.lower() == '.tif': ds = gdal.OpenShared(os.path.join(WorkingFolder,f),gdalconst.GA_Update) gt = ds.GetGeoTransform() gtLst = list(gt) gtLst = 0.36 gtLst = -0.36 # apply the changes ds.SetGeoTransform(gtLst)
Has anyone done anything similar? or know a better solution for matching big tiffs to subtract? I believe that i am able to match the extents and do all other calculations, but the pixels are driving me crazy