Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using QGIS. I would like to clip a raster precipitation layer using an admin boundary layer that is vector data. However the geoprocessing tools seem to be usable only for vector data. How can I clip this precipitation layer?

Thanks for any help!

share|improve this question
Did you really mean for "vector" to appear twice in this question? – whuber May 23 '11 at 15:23
@whuber - not in particular...does it matter in this forum? – Kirk May 24 '11 at 15:05
I couldn't make sense of the question without changing one of the "vector" to "raster." I think I get it now: you are saying you think the geoprocessing tools are only applicable when all elements are vector data. The confusion was that you explicitly say the boundary layer is in vector format, and as that is the immediate precedent, it makes the question ambiguous. – whuber May 24 '11 at 15:19
I have the same problem as the original question - the clipping tool using the gdal plugin works, but it only clips in rectangles.....what if you need to clip it to something like a country border? – Matt Jun 14 '12 at 16:53

Install the GDAL plugin and then use the Clipper Tool.
enter image description here

share|improve this answer
The "gdal tools" aka "raster tools" plugin is installed by default since qgis 1.5, if I'm not wrong. No need to install it manually. – Giovanni Manghi May 23 '11 at 18:57
I found that this tool adds a band to the raster. It uses the command dstalpha. – BWill May 31 '11 at 13:19
As Pablo has written, Clipper Tool is the answer. In qgis 1.7.0, the name of the plugin is "GdalTools". The tools (along with the "Clipper" we're looking for) are added to the Raster menu after enabling it with qgis plugin manager. – amp May 10 '12 at 7:43
Please not that raster and vector data must be saved on disk in the same CRS. Simple png files and delimited text layers with CRS set in QGIS will not work. – AndreJ Dec 14 '13 at 15:56

if you interested with python, you can read a good doc. at, here.

and source is here.


The Process

Clipping a raster is a series of simple button clicks in high-end geospatial software packages. In terms of computing, geospatial images are actually very large, multi-dimensional arrays. Remote Sensing at its simplest is performing mathematical operations on these arrays to extract information from the data. Behind the scenes here is what the software is doing (give or take a few steps):

  1. Convert the vector shapefile to a matrix which can be used as mask
  2. Load the geospatial image into a matrix
  3. Throw out any image cells outside of the shapefile extent
  4. Set all values outside the shapefile boundary to NODATA (null) values
  5. OPTIONAL: Perform a histogram stretch on the image for better visualization
  6. Save the resulting image as a new raster.

i hope it helps you...

share|improve this answer
This answer can be more fruitful if you add some software tool to how to convert shafefile to matrix etc. – Waseem Ali Oct 26 '14 at 14:48

I'm not sure of how to do it in QGIS, howver you may use another open source GIS software such as GRASS or GDALWarp to clip your raster. See keymirror and geographika answers below.

Clipping a raster using a polyline or polygon

share|improve this answer

I'd recommend using gdalwarp as you can increase the efficiency of the process. Imagine you want to cut a raster inraster.tif with a shapefile extent.shp:

gdalwarp -cutline extent.shp -crop_to_cutline -of GTiff -dstnodata 255 inraster.tif inraster_cropped.tif -co COMPRESS=LZW -co TILED=YES --config GDAL_CACHEMAX 2048 -multi

The last two parameters allows you to boost the process using 1) a multicore implementation and 2) setting the cache available to the function.

share|improve this answer

protected by Community Jun 14 '12 at 18:03

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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