QGIS clipper problem when mask used

QGIS clipper problem when mask used

I have encountered a problem with the raster>extraction>clipper function in QGIS when a mask layer is used.

In the image below the diagram on the left shows part of the original raster.

The diagram in the middle shows the original with one of the red areas overlain by a polygon.

The diagram on the right shows the raster created by the clipper function using a mask.

Notice that the pixels in the clipped raster (on the right) are not in their correct location - offset downwards.

There seems to be an offset across all of the output file. The offset is approx 130 m. Does anyone have any ideas as to why this happens? It does not happen when the extent option is used instead of mask.

I am using QGIS 2.8.1 (same happens in a previous version - 2.4). The mask layer and raster layer are in the same CRS.

Note that clipper tool (from raster menu) distort your output, or may distort it by changing cell size. My suggestion is to use the clipper under gdal tools from the toolbox.

There define-tr resx, resyin the additional parameters window; where both resx & resy > 0. Those stand for the input raster resolution, and forces the output to keep it. You can get the resolution from the properties>metadata of your input raster. Note that it will be written like this: 30.0, -30.0; thus modify it to be 30.0, 30.0.

The image below sum it up with an example:

I had the same problem. Note that I'm now using 2.18 version of QGIS where now there is "keep resolution" option. Using both "save as" or Raster>Extraction>Clipping, both give me a raster with a slight offset, where the first pixel is aligned with the mask layer.

The solution is to use the clipper under gdal tools and select both options

  • Crop the extent of the target dataset to the extent of the cutline
  • keep resolution of output raster.

That results in a subset with the pixels aligned with the original raster.

Watch the video: How to Clip a shapefile in Qgis