Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Filter by Categories
ArcGIS Pro

Select NULL values in QGIS

How to select NULL values in QGIS

To select NULL values in QGIS, you can use the attribute table or the “Select by Expression” tool.

Here’s how you can do it step-by-step:

  1. Open Attribute Table:
  • Open your layer in QGIS.
  • Right-click on the layer in the ‘Layers’ panel and select Open Attribute Table.
  1. Select by Expression:
  • Click on the Select features using an expression button in the attribute table toolbar (it looks like an epsilon symbol: ε).
  • In the expression editor that opens, write an expression to find NULL values in a specific field. For example, if your field name is “Area”, you would use:
    "Area" IS NULL
  • Click Select to apply the expression. This will select all features where the value in the “Area” field is NULL.
  1. View Selected Features:
  • The selected features (with NULL values in the specified field) will be highlighted in the attribute table and on the map.

This method allows you to specifically target and manipulate data entries that contain NULL values in QGIS, which can be particularly useful for data cleaning or preparation tasks.

What are Null Values in QGIS?

In QGIS, as in many other database and GIS systems, a NULL value represents the absence of a value. It indicates that the data is missing or unknown for a particular field in a dataset. Here are a few key points about NULL values in QGIS:

  • Unknown or Unspecified: A NULL value signifies that the information is not specified or the value is unknown. It is different from having a zero, blank, or any default value, which are considered specific known values.
  • Placeholders in Data: NULL values often appear as placeholders in datasets where data collection is incomplete or the applicability of a data point is not established. For example, if a survey collects age data but some respondents choose not to provide their age, those entries might be recorded as NULL.
  • Handling in Calculations: NULL values need careful handling during data processing and analysis because they can affect the outcome of calculations and operations. For instance, arithmetic operations involving NULL usually result in NULL, which could influence the results of statistical calculations, spatial analysis, and more.
  • Filtering and Replacing: QGIS provides tools and expressions to filter, replace, or manage NULL values, such as using conditional expressions in the Field Calculator to replace NULL with a default value or exclude them from analysis.

Frequently asked questions about handling NULL values in QGIS:

What is a NULL value and how does it differ from an empty string or zero?

    A NULL value in a database or a GIS system like QGIS represents the absence of a value, indicating that the value is unknown or undefined. This is different from an empty string, which is a string with no characters and is considered a valid, known value. Zero, on the other hand, is a numeric value and represents a specific quantity. Understanding these distinctions is crucial because they affect how data is processed and analyzed. NULL values can cause errors or unexpected results in calculations if not handled properly.

    How can I replace NULL values with another value in QGIS?

      To replace NULL values in QGIS, you can use the Field Calculator. Here’s how:

      • Open the attribute table of your layer.
      • Click on the “Open Field Calculator” icon.
      • Create a new field or update an existing one.
      • Enter an expression to replace NULL values. For instance, if you want to replace NULL with zero in a numeric field named “Population”, use: coalesce("Population", 0).
      • Click “OK” to apply the changes. This expression uses the coalesce() function, which returns the first non-NULL value in the list of arguments.

      Can I filter out NULL values when performing calculations or creating expressions?

        Yes, you can exclude NULL values in expressions using conditional functions. For example, if performing a calculation on a field named “Sales”, you can use an expression like: sum(case when "Sales" is not NULL then "Sales" else 0 end). This ensures that NULL values are treated as zero or simply ignored, depending on the desired outcome.

        How do I identify fields with a high frequency of NULL values in a large dataset?

          In QGIS, you can use the “Statistics Panel” to quickly analyze the occurrence of NULL values in each field. Access this panel from the View menu or use an expression in the Field Calculator like count(NULLIF("Field", 'is not NULL')) to count NULL values in specific fields, helping you identify fields that may require data cleaning or further inspection.

          What impact do NULL values have on spatial analyses in QGIS?

            NULL values can significantly affect the outcome of spatial analyses in QGIS. For example, NULL values in fields used for spatial joins or weighting in interpolation analyses might lead to incomplete or skewed results. Proper handling, such as replacing NULLs with default values or excluding such features from analyses, is crucial.

            How can I use NULL values to control or modify the behaviour of conditional expressions?

              NULL values can be utilized strategically in conditional expressions to dictate the flow of data processing. For instance, using the coalesce() function in an expression allows you to provide fallback values where data might otherwise be undefined, ensuring that your GIS workflows continue smoothly without interruption.

              Are there specific functions or plugins in QGIS that help manage NULL values more effectively?

                While QGIS does not have specific plugins solely dedicated to handling NULL values, several core functions like coalesce(), ifnull(), and nullif() in the Field Calculator can be effectively used to manage NULL values. Additionally, plugins that enhance data management might indirectly assist in handling NULL values more efficiently.

                About the Author
                I'm Daniel O'Donohue, the voice and creator behind The MapScaping Podcast ( A podcast for the geospatial community ). With a professional background as a geospatial specialist, I've spent years harnessing the power of spatial to unravel the complexities of our world, one layer at a time.