Is there a setting I can change in order to get all the pixels of the raster layer which are touched by the vector boundary in the clipped image? Right now, only those pixels which lie completely within the boundary are included, and it's causing issues.
2 Answers
I've not tried this, but there appears to be an option in gdalwarp called CutlineAllTouched
CUTLINE_ALL_TOUCHED: This defaults to FALSE, but may be set to TRUE to enable ALL_TOUCHEd mode when rasterizing cutline polygons. This is useful to ensure that that all pixels overlapping the cutline polygon will be selected, not just those whose center point falls within the polygon.
You should be able to call this using the wo (warp option). You should be able to edit the command line using the 'pencil' icon to add this option when using Raster>Projections>Warp
gdalwarp -wo CUTLINE_ALL_TOUCHED=TRUE ... other settings...
As of now (2024) it seems, gdal:cliprasterbymasklayer
, which is based on gdalwarp
retains only pixels, whose center-point lies within the clipping mask.
I needed to have only pixels that do not stretch farther than the clipping mask (solid line). I found applying a negative buffer with half the raster resolution (dotted line) to be a relatively easy way to deliver me an acceptable solution. I didn't think through it for all possible cases.
A positive buffer could be applied to get a raster covering the clipping mask completely.