4

I have downloaded a couple of (Sentinel-2) raster files and would like to clip them down to be a smaller size. However, when I clip them the output file has a wider range of pixel values than the original file. For example, I clipped Band 2, which originally had values ranging from 0-1501. However after I applied the clip function reducing the total number of pixels the values ranged from 0-2132. I also tried mosaicking my (overlapping) files taking only the maximum value for each pixel to get rid of the 0 value areas and found the same thing to apply. I have tried this in QGIS 3.16.11 and also in 3.24.0 and no difference between the results.

Can anyone shed some light on what is happening here? I intend to use the pixel values to calculate NDVI so it is important that they are correct.

2
  • How would I go about doing this? Is it separate to the clipping options?
    – ecoQs
    Commented Mar 9, 2022 at 5:45
  • That works perfectly! You are correct, the exact numbers make a lot more sense. That makes it the original range being 0-3902 and the clipped range being 0-3480. Thank you!!
    – ecoQs
    Commented Mar 9, 2022 at 6:11

1 Answer 1

7

They're unlikely to have actually changed. These issues are usually caused by incorrect or poorly sampled approximate statistics. Recalculate the original and clipped statistics using exact instead of approximate method.

There's a few ways to do this

  1. Use the raster information tool and tick the first two min/max and stats options.
  2. There's also the raster layer statistics tool, but the help doesn't state whether it uses exact or approx stats.
  3. You can also specify to use exact stats in the raster layer properties - symbology - min/max values

Alternatively, use gdalinfo from the commandline:

gdalinfo -mm -stats your_raster.tif

This is exactly what option 1 above does.

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.