1

I have table, many rows, with column "landuse" (code numbers). I need column with text. How to do this in Field Calculator?

I mean this:

landuse   
200               
300               
1231              
300              
200         

new column:
wood
field
road
field
wood

EDIT

I have a solution...

CASE 
  WHEN "lu" IS 200 THEN 'Vacice virginska'
  WHEN "lu" IS 700 THEN 'korytnačkař'
  ELSE 0
END
1

2 Answers 2

3

Create a table with landuse_number and landuse_text, populate with unique values (one for each landuse), join this table with your shape data on landuse_number and then you can perform a field calculation to transfer the text values over permanently to a new field, or just work with them joined. Join tutorial can be found here: http://www.qgistutorials.com/en/docs/performing_table_joins.html

3

You need to add Field of type Text, and select a length of 20. You can name the new field "Class". Then, use Field calculator to update the "Class" field using the following formula:

CASE 
WHEN  "landuse" = 200 THEN 'wood' 
WHEN  "landuse" = 300 THEN 'field' 
WHEN  "landuse" = 1231 THEN 'road' 
END

Whether you use is or =, the expression is correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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