4

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.

enter image description here

2 Answers 2

2

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, resy in 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:

Example

2
  • 1
    Thanks for that - i ran the function but for some reason kept getting error saying invalid source however, when I clicked the option 'Keep resolution of output raster' on and left out the paramerter -tr - it worked. So thanks again for that.
    – Aquamarine
    Apr 19, 2015 at 16:32
  • I tried it with the 'keep resolution of output raster' without -tr and it didn't work; only work with -tr for me
    – dof1985
    Apr 19, 2015 at 20:17
0

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.enter image description here

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. enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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