[GIS] QGIS: Clip Raster by Mask Layer-permanently remove black edges

clipmaskingMATLABqgisraster

I want to introduce geotiff images generated in QGIS by clipping ortho imagery to a shapefile into matlab. However, the clipped raster images come with black borders. I managed to remove them in QGIS (by setting a no data value for zero/ black), but they return when I open the same images in matlab. Even when I check the "create an output alpha band" box, the same thing happens in matlab. Any solution?

Best Answer

It seems to me that Matlab GeoTIFF reader can't deal with nodata value or with alpha channel https://se.mathworks.com/help/map/ref/geotiffread.html. Transparency is available only for PNG, CUR and ICO files https://se.mathworks.com/help/matlab/ref/imread.html. Therefore the only way to remove the nodata areas from Matlab on QGIS side is probably to save the image as PNG with alpha.

By this old answer you should be able to remove regions from a raster with Matlab by using a vector mask. The mask can be a shapefile.

https://stackoverflow.com/questions/22000272/how-to-limit-the-raster-processing-extent-using-a-spatial-mask

Related Question