I have a new column in my attribute table with a lot of null values and I want to replace all them to zeros.
How can I do that in field calculator?
I'm using QGIS 1.8
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
In QGIS open your attribute table and click the "Select Features Using an Expression" button. To find all the null records for a field in a shape file your query will look like:
"field_name" is null
You can find your field name in the Fields and Values list, double click the field you want to get it into the Expression box.
Make sure you SELECT the new filtered list of records. Then go back to the attribute table and click the Field Calculator button. Check the "Update Existing Field" box - ensuring that the 'only update selected' check box is selected, then select the field you want to update from the dropdown box. Put 0 in the expression box, click OK and you're done.
You can do this directly in the field calculator:
if("fieldname" is null, 0, "fieldname"), replacing
fieldnamewith the actual name of you field
It would obviously be safer to create a new field rather than overwriting the old, in case anything goes wrong.
I just realised that you could edit the –.dbf– file of your shape folder and insert there a new column, row, etc. So! for actualizing the master table of your map. Just find the file i.e.: LATINAMERICA.dbf, open it with LibreOffice (at least I opened it with "Spreadsheets", and it worked perfectly) edit it and then save it as .dbf with the same name and in the same folder. Then reopen the map, and it will have the changes in the master table...It worked for me (Qgis WIEN 2.8) I hope it will work with you all because it was a real pain find that solution.