I am trying to rasterize a shapefile using the "rasterize" tool in qgis. The problem is that the resulting raster doesn't seem to rasterize correctly...

The teal and purple lines show water flow, and this is the shapefile I would like to rasterize

The resulting raster takes all of the extent of the file and gives it a value of 1, even if it is not part of the water flow


  • How so? Is there no/blank output or is the output wrong? Are there any error messages? Is it the black boxy outside that's the problem? Can we have a screen shot of the tool with the options filled out please. – Michael Stimson Apr 22 '15 at 1:06
  • I do get a raster, I just added printscreens of the results... :( – Nadia Apr 22 '15 at 1:07
  • 3
    Really need to see the tool dialog, is it possible that your cell size is so large that it's ignoring your lines? – Michael Stimson Apr 22 '15 at 2:32
  • 2
    +1 Michael - Though I think the problem is not ignoring the lines but the density of lines in comparison to the raster cell size. The apparent cell size of the raster in the image appears to be considerably larger than any flow line. If the raster is just a Boolean (stream vs no stream), then I am not surprised QGIS gives 1 everywhere as every cell will contain at least one flow line! – MappaGnosis Apr 22 '15 at 6:55
  • I just added a screen shot of the tool dialog... I think that you are right guys, the pixels are big and the lines are fine... how can I find the correct pixel size for the lines? – Nadia Apr 22 '15 at 16:59

Assuming that your projection is in meters, the procedure for rasterizing include:

1) At the layer properties, copy the extent of your 'rivers' shapefile and remove the text characters. In my example is:

168902.13 85311.7 831499.38 1271303.48

enter image description here

2) Click in Raster -> Conversión -> Rasterize menu option. Select the output file name and, afterward, click in "Raster resolution in map units per pixel". I assume a pixel size of x = 30 m, y = 30 m. Now, click in the pencil icon and paste in the gdal_rasterize command, before pixel size, your equivalent to this:

-te 168902.13 85311.7 831499.38 1271303.48

The complete command, in my case, would be:

gdal_rasterize -a id -te 168902.13 85311.7 831499.38 1271303.48 -tr 30.0 30.0 -l rios_utm19prj /home/zeito/Desktop/UTM_19_latlong/rios_utm19prj.shp /home/zeito/Desktop/UTM_19_latlong/rivers_raster.tif

enter image description here

3) After click in OK, 'Zoom In' to one arbitrary area of the output raster (rasterized by ID and with pseudocolor renderer) where it can be observed that the rasterization is as espected:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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