I have a shapefile with attribute table that has number fields that have five zeros after the decimal point, having been imported that way. I don't need decimals and want the figures as simple intigers. How can I convert them in QGIS?
2 Answers
Open attribute table and go to field calculator, then create new column (integer) with expression "YourColumnName".
Obviously you have to change YourColumnName with name of your column where you have old values.
-
1That is absolutely brilliant Works fine. - thank you. I even know how to spell "integer" now!!! Dec 9, 2016 at 15:32
To convert real to integer in an expression, you can round the real number, convert to string and then convert to integer:
to_int( to_string( round("yourfieldname") ) )
It is a bit convoluted, but it works for me.
-
You don't need to convert it to string or round it. to_int(doublenumber) rounds it to an integer in field calculator.– AsierNov 28, 2020 at 14:13
"fieldName"
). Or you can use the expressionto_int( "fieldName" )
to convert your real number to integer.