8

I have some rasters representing string categorical variables. Each raster contains integers, used to translate the categorical variables. I have also the .csv tables giving the meanings of the integers used in the rasters (1='Corn'; 2='Soybean', etc for example).

Is there a way to combine the rasters and the tables in order to:

a) Display the strings and not the integers when I use the "Identify Features" tool?

b) Use the strings instead of the integers in the Raster Calculator tool?

I am a QGIS 2.4 user on Windows.

1
  • You can do this at database, ex. if you using PostGIS. Commented Sep 24, 2014 at 12:00

4 Answers 4

4

You may be able to do those things if you import your raster into a PostGIS database (I have not used PostGIS but I have heard wonderful stories about it). Alternatively, and you may have already done this, you could insert your categories into the legend:

Raster Properties

Raster legend

However, using the "Identify Features" tool will still only show you the integer values and not the strings. I don't think you can use the labels in the Raster Calculator. Apologies but hopefully someone can provide a definitive answer for you.

1
  • Thank you Joseph. But you are right, it would be nice to get a more definitive answer.
    – Bap
    Commented Sep 18, 2014 at 21:48
0

I have been looking for something in QGIS but to no avail, unless you are interested in writing a code in Python. I know the question is tagged with QGIS, but the solution could help.

If you are familiar with ERDAS IMAGINE, it has a tool that does the required. Check this help article, Raster Attribute Editor.

It will do the exact thing you need, that is assign attributes to pixel values. Hope this helps.

0

The only way I have done something of this nature in QGIS, or other GIS packages was to polygonize the raster. In other words. I had the software create a polygon for each pixel in the image, and transfer the pixel value to the new polygon file. You are then able to query that value from the table, or join, and update that table with the .csv file.

This utility is available in the QGIS toolbox. It was very straightforward to me.

0

A workaround could be to convert the raster to a vector, and then do the join

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.