1

I try to rasterize a multiline data set (streets) from a PostGIS database using QGIS 2.18 and SAGA GIS rasterize tool.

I managed to differentiate between street and not street but I'd need to differentiate the raster value for different road classes (1-10). I tried to set the attribute field as the respective field and chose attribute in the output value field. SAGA GIS rasterize Unfortunately, output seems to be more as an index from 1 to 2500 than values from 1 to 10.

I also tried GDAL rasterize and GRASS v.to.rast.value. Output of the GRASS GIS is just binary (street/no street)

In the end I'd need a "categorized" raster for diffeerent kinds of road types and nodata values in the other area. It will be one layer of a suitability analysis which I plan to do with raster calculator.

Question:

How can rasterize a multiline vector file and keep the value of a particular attribute?

update 1: SAGA GIS uses the value of ID field instead of "_objectval_id_. update 2: GDAL tool would work, but I'm not able to set the raster resolution properly. update 3: obviously SAGA GIS rasterize only works when the attribute is unambiguous assigned. So I'd have to use indices for every road class or create for every class a single raster layer. correct?

  • solution: I created a new field with field calculator as ` CASE WHEN "id" <10 THEN "Objectval_ID" || '.' || 0 || 0 || "id" WHEN 9< "id" AND "id"<100 THEN "Objectval_ID" || '.' || 0 || "id" WHEN 99< "id" THEN "Objectval_ID" || '.' || "id" END ` Rasterizing this with SAGA Rasterize tool into integer gives only the road value! – Kevkev770 Jan 22 '18 at 18:08
  • You should post your comment as an answer :) – Joseph Jan 23 '18 at 12:09
  • @Joseph, thx; I wasn't sure if this is a solution or just an odd workaround... – Kevkev770 Jan 23 '18 at 12:17
  • It could be both :). But as long as it helped you solve your problem, it should be posted as an answer as it could help others with a similar problem. – Joseph Jan 23 '18 at 12:19
1

I created a new field with field calculator as

CASE WHEN "id" <10 THEN "Objectval_ID" || '.' || 0 || 0 || "id"
        WHEN 9< "id" AND "id"<100 THEN "Objectval_ID" || '.' || 0 || "id"   
            WHEN 99< "id" THEN "Objectval_ID" || '.' || "id" 
END

Rasterizing this with SAGA Rasterize tool into integer gives only the road value!

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.