12

I have successfully joined data from a csv file to a shapefile in QGIS but for some reason I am having trouble symbolizing my data.

I want to use a graduated symbology however this option is not available for any of the columns for my joined table.

I have tried saving as a new layer but this does not change the issue.

Has anybody got any tips to get around this?

7 Answers 7

12

The problem most likely is that all CSV columns have been imported as text fields. Text cannot be used for graduated styles.

To fix this, you need a .csvt file for your CSV which specifies the data type of CSV columns explicitly. Basically, a .csvt file is a text file with only one line, e.g.

"Integer","Real","String"

For a CSV file with three columns. More info: http://underdark.wordpress.com/2011/03/07/how-to-specify-data-types-of-csv-columns-for-use-in-qgis/

You'll be able to verify if specifying data types worked, by checking the csv layer's "Fields" tab and the data types listed there.

1
  • important detail: the csvt file must have the same name of csv file, and don't need to be imported just kept in the working directory
    – Lucas
    Commented Apr 20, 2020 at 0:34
3

I was tried using the CSVT file too but got better results by simply saving a Libre Office spreadsheet to a DBF.

Then bring in the DBF into QGIS as a vector layer - and it will come in as a table.

The fields in the DBF in QGIS seem to auto-format quite nicely, whereas I couldn't get the CSV / CSVT file to work at all.

1

The problem is that your variables can't be categorized if they are not in the right format. So since it's not working, I guess they're not quite right... I found myself with the same problem and it took a while to sort it out. Do this:

  1. Select your shapefile, right click on it, go to properties and then to 'Attributes' or 'Fields' (depending on your QGIS version)
  2. There you can check whether your (joined) variables are integers, strings, etc... I repeat, if they are integers or text, you won't be able to do your thing
  3. You can change their format easily. Open your data in excel and then select the column you need, then click on Data and then Text to Columns (if you have any issues with this transformation just google from text to numbers in excel or something like that).
  4. Then just do the join once again.

Good luck!

0

Yes, your data might be in string and not a numeric value, which graduated symbol options require. If your data-set is not very large, open .csv file in excel and select the columns and paste as values. Save it in .xls or *.xlsx format and you are good to go.

0

I had the same problem, saving the table from open office as a dbf file, then doing a little editing of column headers so they were continuous strings with no spaces or punctuation did the trick.

It was then possible to take them in via the QGIS browser window into layers and then link them to the shapefile layer I was using

0

The post has been a while ago, but seems the best way is to use QGIS with ReFactored:

https://wiki.tuflow.com/index.php?title=QGIS_Change_Attribute_Type

0

Use the "Refactor fields" tool to change the column you want to map from string to int. Only integers can be selected.

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.