I am using QGIS tool "Clip raster by mask layer" in Processing Toolbox for clipping satellite(georeferenced) image raster using shape polygon with "clip to mask layer's extent" setting switched on.
I observed that the output clipped raster's pixels have an offset of around 0.5 pixel size with respect to source image.
Apparently there is a mistake in the algorithm of this tool especially while setting the Geotransform (which decides the positioning) of the output clipped raster.
How can I access the algorithm of this tool?
EDIT:
Found that the pycode ClipByMask.py is apparently (correct me if needed) not the code I am looking for, since it returns argument that calls other GDAL code. Below is the line that shows it:
return ['gdalwarp', GdalUtils.escapeAndJoin(arguments)]
Also observed that the pycode ClipByMask.py has following imports:
from processing.algs.gdal.GdalAlgorithm import GdalAlgorithm
from processing.algs.gdal.GdalUtils import GdalUtils
I was looking for the lines which contain geotransform[0] and geotransform[3] which define the positioning of the image top-left corner, but only found:
arguments.append(unicode(geoTransform[1])) arguments.append(unicode(geoTransform[5]))
above lines are related to only pixel width and height.
I am in search of the GDAL code that has code snippets that involve positioning the raster and has functions to do the raster clipping operation.