TransWikia.com

Replacing all null values from attribute table with zeros in QGIS

Geographic Information Systems Asked on June 15, 2021

In QGIS 1.8 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?

3 Answers

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.

Correct answer by HeyOverThere on June 15, 2021

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.

Answered by Francisco Vergara Perucich on June 15, 2021

You can do this directly in the field calculator:

  • Open the field calculator
  • Check the “Update Existing Field” box
  • Select the field you want to work on
  • Enter the following expression in the expression box: if("fieldname" is null, 0, "fieldname"), replacing fieldname with 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.

Answered by leo on June 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP