1

I am trying to join a .csv-file with als rates and zip3 values to a shapefile with zip3 values and then color the map based on the als rates.

This seems very simple and I have done similar maps before but I am having trouble with the field types. Whenever I import the CSV it makes all of the field types strings and I am not able to change them even using the refactoring toolbox. Then when I join them they are still strings and I am not able to style them using graduated symbols because they are not numerical.

Here is a link to the shapefiles and the csv that I am using: https://drive.google.com/drive/folders/1X26BXzrCtjSGuAPweH3HPiGshcfGaU6U?usp=sharing

I am using QGIS version 3.10

1
  • You could run refactor fields on the joined layer?
    – Erik
    Oct 14 '20 at 11:03
3

In the layer style panel, use an expression to convert your string type into real.

Insted of using rates, use to_real("rates") and it will work (supposing your field is named "rates").

works with to_real expression

map example

1

I think @romainbh already gave a better answer, but you can also force QGIS to interpret CSV colums as a special datatype by using a CSV-T.

Therefore create a new textfile, fill it with the column-datatypes of your CSV like this:

"Integer(10)","Real(10.5)","String(80)"

You can use Integer, Real, String, Date, Time and DateTime. Do not add any more content to it. Then save it having the same filename as your actual CSV into the same folder, just having the ending .csvt. If you now load it, your CSV should have the correct datatypes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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