Using the rio.mask.mask function to clip out a section of an ortho. The result .tif looks like it has been "washed" out. The pixel values from the ortho and the result are exactly the same, so seems like QGIS is reading it oddly? I set the symbology of both layers to exactly the same settings and still same issue. Process works on other orthos I have. Only difference is that this ortho has a projection of ESRI:102057 and my orthos that do work have a projection of EPSG:3857. Any additional information I can give?

def crop_ortho2(poly, ortho_dir, output_dir):
    with rio.open(ortho_dir) as src:
        shapefile = fiona.open(poly, 'r')
        shapes = [feature["geometry"] for feature in shapefile]
        out_image, out_transform = rio.mask.mask(src, shapes, crop=True)
        out_meta = src.meta
        out_meta.update({"driver": "GTiff",
                         "height": out_image.shape[1],
                         "width": out_image.shape[2],
                         "transform": out_transform})
        output = output_dir + "0.tif"
        with rio.open(output, "w", **out_meta) as dest:


{'driver': 'GTiff', 'dtype': 'uint8', 'nodata': 0.0, 'width': 16809, 'height': 23231, 'count': 4, 'crs': CRS.from_epsg(6339), 'transform': Affine(0.15, 0.0, 535020.9,
       0.0, -0.15, 4882392.3)}

Ortho enter image description here

Result enter image description here

  • 1
    It looks like your fourth band (near IR?) could be getting interpreted as alpha / transparency. Maybe try setting the ALPHA=unspecified gtiff creation option?
    – mikewatt
    Jan 27 at 19:33
  • Interesting... I thought I was just handling RGB, but it does look like there is a near IR band. I'll have to check with the src acquisition about that. Let me get back to you on that and EXCELLENT discovery/idea!
    – Binks
    Jan 27 at 19:41
  • @mikewatt that worked beautifully! Thank you for teaching me something! Please post your answer!
    – Binks
    Jan 27 at 19:53
  • Awesome. Will do!
    – mikewatt
    Jan 27 at 19:57

1 Answer 1


This can be caused by the fourth band being interpreted as alpha / transparency. If that's the case, setting the ALPHA=unspecified geotiff creation option will tell the viewing software to ignore it instead.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.