29

How do I crop a raster layer in QGIS?

I want to make contours from a section of a layer, and including the whole layer will create far more data than I need and slow down the rendering.

I have found that I can do it by using the Raster calculator and specifying a new layer extent, but how do I know what values to enter for the rows and columns?

I also tried cropping the geotiff in Photoshop, but it seemed to lose the coordinate data.

Is there any way to create contours from part of a raster layer without having to crop it first?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Graham vdR
  • 303
  • 1
  • 3
  • 6
  • 1
    somehow related http://gis.stackexchange.com/questions/10117/how-to-clip-a-raster-with-vector-boundaries – nadya Dec 24 '12 at 03:18
  • 1
    Be careful whenever you crop a raster. If you crop to a non-multiple size you'll get unaccurate not-integer pixel size and it can get messy if you did not realized in time. –  Jun 24 '13 at 17:50

3 Answers3

45

The Raster|Extraction|Clipper tool will help you to do this.

You can open the tool and then click and drag in the raster image to select the area you want to export as a new raster (Clipping mode: Extent), and then refine the exact coordinates in the Extent fields (if necessary).

Probably no way to do contours on only a selection of a raster; clip it this way first!

Simbamangu
  • 14,773
  • 6
  • 59
  • 93
  • This helped me out enormously. Dutch ANH3 data comes in very large chunks and some processing code bugs out when it tries to process it. I was able to use QGIS to clip the area down and got some 0.5m resolution data for just the required area. Perfect! – Steve Hibbert Jan 18 '22 at 15:43
3

I think the previous answer needs to fill extent by hand, since a better, automatic solution is:

go to Processing toolbox and call "Crop to data" SAGA (Raster Tools) process.

pnz1337
  • 1,565
  • 1
  • 13
  • 25
2

A quick update to @Simbamangu's answer as of 2022.

  • In the current version of QGIS (I use 3.2x) click menu item Raster -> Extraction -> Clip Raster by Extent.
  • In the tool window that opens choose the raster layer you want to crop as Input layer (if not already chosen in your layer window).
  • Click the menu to the right of the Clipping extent input field (see screenshot).
  • Click and drag over your raster image (the selection box is almost invisible).
  • Set a filename and path under Clipped (extent)
  • Click Run.

enter image description here

petezurich
  • 135
  • 7