I am creating NDVI from Sentinel2 bands 8 and 4 on QGIS, using the raster calculator, but I need to convert the format or clip to a polygon beforehand, because my computer crashes if I try to perform on the raw bands.

If I convert the bands to 32bit beforehand (needed for the end product anyway) or if I clip to polygon to make the raw band a smaller extent, I am finding the raster values change, and not in a consistent manner. These are some of the differences found between my 'processed' bands and the original bands, comparing my processed NDVI to the calculated NDVI from the raw bands.

enter image description here

I used GDAL warp (near resampling, LZW compression) to change the data type from UInt16 to 32b Float. I also trialed using GDAL translate (no compression) to do the same, and still found the values changed significantly and inconsistently.

Is this all to do with resampling?

Is there any way to do this sort of processing on QGIS without altering my raster values?

1 Answer 1

 import gdal
 import os

 input_path = r"D:\ESCUELA\GIS_StackChange\input"
 out = "D:\ESCUELA\GIS_StackChange\output"
 area_shape =r"D:\ESCUELA\GIS_StackChange\input\Area_work.shp"

 bandList = [band for band in os.listdir(input_path) if band[-4:]=='.TIF']

  iter = range(len(bandList))

  for i in iter:
        clip_imag = gdal.Warp(srcDSOrSrcDSTab = input + '\\'+ bandList[i],
                cutlineDSName = area_shape,

this script, clip your images with your work area (shape area). Also, do not expect the values ​​of the raster cilp to be the same as the original raster, because the extreme values ​​of the pixels will not be the same since they are not the same area.

  • if you follow your error let me know for see the part of the ndvi May 6, 2020 at 2:41

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.