0

I am trying to display a graduated symbology for a vector layer based on UK postcodes, but having major issues.

I have the postcode vector layer, and my data set is UK Postcode Lending data, where I've taken only the last column of data (Q2 2019) and saved this (along with the postcode sector as column 1) as a csv and uploaded to QGIS 3.12.3 Bucaresti. I'm running a Macbook Pro 2016, Mac OS Catalina 10.15.5. So far so good.

I've then joined my attribute only table of postcode lending data with the vector layer of UK postcodes, using postcode sector as the join. The join goes through, but the lending data gets saved as a Qstring text layer, not as an integer, no matter what I do. This is where the problem starts, as QGIS obviously can't make graduated symbology from a text attribute type.

I've tried to run Refactor Fields from the processing toolbox, but this doesn't change the attribute type for some reason, even though that's what it's supposed to do.

I've also tried reformatting and importing the CSV file so that QGIS imports it as an integer type off the bat - again, no dice.

These are the only two solutions I can find on the message boards, and I don't know why it's not working.

1
  • Add a new field in the attribute table, field calculate as to_int( "somejoinedfieldname")
    – Bera
    Commented Jul 16, 2020 at 11:56

1 Answer 1

1

After selecting "Graduated" as your layer styling type don't try to choose your text field in the drop-down selector but click on the Ɛ symbol just right to it, this will open the expression dialog window where you could use an expression to convert your value to integer.

It should work by using to_int( "yourfieldname" ) as expression

1
  • 1
    Hey JR, thanks so much for your comment. Remarkably this worked, even though I was sure I had already followed these exact steps already. I think the one difference may have been that I tried to select the text field first, then ran "to_int". Running the expression straight away seems to have solved my issue. Many thanks and apologies for the issue being rudimentary after all!
    – Junta
    Commented Jul 16, 2020 at 16:23

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.