I am using below codes to mosaic some raster files, but the result shows many white blocks.

Did I miss any important option to avoid this?

The codes:


        String folder = "";
        String outputFile = folder + File.separator + "result.tif";
        Collection<File> files = FileUtils.listFiles(new File(folder), new String[]{"TIF"}, false);

        List<Dataset> datasets = files.parallelStream().map(file -> {
            return gdal.Open(file.getAbsolutePath(), 0);

        gdal.Warp(outputFile, datasets.toArray(new Dataset[0]), new WarpOptions(new Vector<>(Lists.newArrayList(
                "-r", "near"
  • one of the original Tiff file:


  • The mosaiced raster tiff shows white blocks:

enter image description here

New contributor
cinqS is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I wonder if you have actually black pixels and nodata=0 that makes your viewer to show the pixels as transparent. We need more details about your options and perhaps sample data.
    – user30184
  • @user30184 I checked both the original tif and mosaiced tif, they both have nodata value as 0. and added -dstnodata 0 didn't help.
    – cinqS
  • What is your viewer? Does it have a tool for checking the value of those white pixels? Are they nodata (0) or white (255)?
    – user30184
  • @user30184 I am using an open source Qgis, yet I am not sure how to get the value from the viewer. But I can copy the coordinate with qgis, and know how to read byte array with gdal. Can I use these coordinates to get the value?
    – cinqS
  • Select the layer in QGIS and use the normal query tool. The name seems to be "Identify features", a small "i" as an icon.
    – user30184

Your Answer

cinqS is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.