0

This question already has an answer here:

I'm quite new to QGIS and I guess my question is quite simple but yet I couldn't find out how to do this successfully

I Have a 'roads' string column with text such as:

primary

secondary

etc.

and I want to make a new column/layer that which I give an integer value such as:

1

2

Respectively

So I can later Rasterize the layer

Any Ideas?

marked as duplicate by underdark qgis Jan 7 '18 at 11:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • so if the field "roads" says primary the new column should say 1? – LaughU Dec 20 '17 at 14:48
  • 1
    So what have you tried? Your question is no doubt a duplicate of alot of questions on this site. – BERA Dec 20 '17 at 14:51
3

you can use the CASE statement in the field calculator:

CASE 
  WHEN "roads" = 'primary' THEN 1
  WHEN "roads" = 'secondary' THEN 2
  ...
END

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