[GIS] Problem rasterizing

qgisrasterization

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


Dialog

Best Answer

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

Related Question