I have three Sentinel 2 rasters for band 4 (named tile1_B04, tile2_B04, tile3_B04) and my area of interest is clipped by merging these 3 rasters. 2 out of 3 rasters have 0 pixels in certain portions. While merging if I set "Input pixel value to treat as nodata" to 0, the merged layer looks fine. But if it's set to -9999.00, the merged layer will still have 0 pixels. How do I decide the right nodata value? The rasters are attached for reference.

tile1_B04 tile2_B04tile3_B04

  • I've seen this question being asked before, perhaps search this site and you may find an answer. If not, what software do you have available? Any kind of meaningful guidance would be targeted toward your available software. Dec 4, 2023 at 2:38
  • @MichaelStimson I'm using QGIS 3.28 LTR version. Yes, I did search for similar queries, some posts mentioned using zero as nodata. However, a couple of video tutorials use -9999 and get the merged layers with nodata pixels removed. What is the right way to tackle nodata values
    – rekha
    Dec 4, 2023 at 10:06
  • The pixel type of Sentinel 2 is UInt16 (unsigned 16 bit integer) but the data only uses 12 of those 16 bits, so negative numbers are out. You would be best to use 65535 as your NoData value. You can extract the background using raster calculator gis.stackexchange.com/questions/110121/… then convert to polygon docs.qgis.org/3.28/en/docs/training_manual/complete_analysis/… edit out the area you want to exclude then use the remaining as a cutline in gdal_warp gdal.org/programs/gdalwarp.html Dec 4, 2023 at 23:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.