11

I have a a column of data that I'm trying to display in the Categorized Style but when QGIS orders the values it ranks them, for example, 57, 58, 59, 6, 60, 61, 62....

Is there a way to rank them in the correct order?

I'm using a Colour ramp and so the colour for number 6 is as dark as numbers 59 and 60, when it should be much lighter.

enter image description here

3 Answers 3

8

In that case you should use a graduated renderer. It will sort the values correctly.

Categorized renderers are meant for nominal scales.

Graduated renderer will only work with numerical values. So if your column is text, you'll have to convert it to numeric format first. As Andre noted in his comment to another answer, this can be done in field calculator with toint(old_fieldname).

1
  • I would be nice though to be able to sort/rearrange the values before they get assigned a style when using categorized. In case its not numbers but maybe some sort of categories represented by text. If the data set is large or maybe located in a database, it might not be possible to create a new column to represent the order.
    – Chau
    Commented Apr 13, 2018 at 8:55
6

Another idea would be to change the column of data to numbers from text (in ArcGIS I add a 'field', remove the shapefile from my work, and then import the .dbf file into open office Calc and turn the text into numbers in the new column then reopen the shapefile with the new improved column of data). Your color ramp will be correct if the software recognizes the numbers (instead of text). Things that look like numbers to me but text to my computer annoy me every day.

1
  • 3
    I think this is the solution. In QGIS, you can add another field in attribute table with field calculator and use toint("<old_fieldname>" ) function to populate the column. You can check if the field is text or number in the fields section of the layers properties.
    – AndreJ
    Commented Jan 30, 2013 at 20:06
0

I would create an additional text column formatted like ...,06,07,08,09,10,11,... This should be ordered correctly.

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.