Hot answers tagged

35 votes
Accepted

What is the difference between != NULL and IS NOT NULL in QGIS filter expressions?

Disclaimer: Because the syntax for filtering in QGIS works with SQL, I'm assuming here that SQL rules apply. I'm not completely sure if that's entirely correct, but it seems logical and it does ...
karpfen's user avatar
  • 2,295
25 votes
Accepted

Concatenating labels in QGIS

This is because concatenate() is an aggregate function (i.e. it looks up the values for that attribute across all features), so when you try for example concatenate("GROUP") you'll still end ...
she_weeds's user avatar
  • 10.1k
24 votes

What is the difference between != NULL and IS NOT NULL in QGIS filter expressions?

NULL is not a value, therefore it cannot equal = or not equal != anything. It is not the same as zero 0 which is a value. A NULL indicates that no value has been recorded in the cell you are looking ...
Midavalo's user avatar
  • 29.5k
23 votes

Replacing all null values from attribute table with zeros in QGIS

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 ...
leo's user avatar
  • 749
18 votes
Accepted

Importing NULL in PyQGIS

The NULL class is defined in qgis.core: import qgis.core if f["SAMPLE"] == qgis.core.NULL: ... Normally you should be able to do a normal is None check however due to tool we use to ...
Nathan W's user avatar
  • 34.6k
12 votes
Accepted

Selecting NULL or date values by Expression in QGIS

I don't know why, but this worked: to_date(field) IS NULL or field > '2020-01-01' Type of "field" is date.
Kadir Şahbaz's user avatar
11 votes
Accepted

Why blank values in attribute table don't work as NULL in QGIS?

NULL is not equal to an empty string. NULL is by definition an "unknown value" of which we cannot assume anything. Whereas an empty string is a string without contents. You can test for ...
Matthias Kuhn's user avatar
10 votes
Accepted

QGIS: Delete all records/rows with NULL values

In the attribute table, choose Select by Expression and write "FIELD_NAME" IS null (replace FIELD_NAME with your actual field names, of course). Click "Select Features", then simply delete the ...
Nathan's user avatar
  • 1,284
10 votes
Accepted

Referring to Null value with ArcPy Expressions?

Your problem is that in Python 2 None is less than everything. >>> None < 20 True >>> None < numpy.nan True >>> None < float('-inf') True >>> None < '...
user2856's user avatar
  • 64k
9 votes

Batch removing null geometries

Removing null geometries from just a few layers Use the "select by expression" button to select features with null geometries. The "select by expression" button is found by clicking the arrow next to ...
csk's user avatar
  • 24.3k
9 votes
Accepted

Handling null inside .map in Google Earth Engine

There is not a great way to skip an image in the map function. However, you can use the ee.Algorithms.If function to control what happens when null is encountered. In your case, if all pixels in the ...
Justin Braaten's user avatar
8 votes

Changing 0 to NULL in QGIS Attribute table

select all your '0' rows -> Go to 'Select by expression' and select all rows where attribute = 0 Go to 'Field calculator' and check 'Update existing field', 'Only update selected features' and select ...
Jane's user avatar
  • 1,066
8 votes
Accepted

Nullifying the whole row in data attribute table at once in QGIS

You can do it with a few lines in the Python console. As with any script which permanently edits a layer in place (this one does), I recommend making a backup copy of your file first. One other caveat-...
Ben W's user avatar
  • 20.2k
7 votes
Accepted

Allowing NULL value in field's value map in QGIS?

Implemented the value maps of Edit Widget Property on one of Reservoirs layer. I have an attribute with type of reservoir (this water body could be Reservoir, Dam, Anicut or even null) and I had no ...
Bhaskar Reddy Pulsani's user avatar
7 votes
Accepted

QGIS constraint not null depending on another field value

On field B, for constraints use this expression: case when "field_A" = 'foo' then not (field_B is NULL) when "field_A" <> 'foo' then field_B is NULL or field_B is ...
Babel's user avatar
  • 63.1k
7 votes

Deleting contents of all entries in field in QGIS Attribute table

You could use the field calculator to update the field to '', aka an empty field. Beware that this is not NULL. As J.R pointed out in the comments, null provides a NULL-value in your field.
Erik's user avatar
  • 15.5k
6 votes
Accepted

Python script for filling <Null> values with previous value in one field

You can do this directly within the CalculateField tool; use the following code block: prevval = None def calcowner(ownerval): global prevval val = prevval if ownerval is None else ownerval ...
Evil Genius's user avatar
  • 6,221
6 votes
Accepted

Calculate all 'Null' integer fields to '0'?

You can do this for many fields with some Python. This is a stand alone example, but it'd be easy to write this into a script/Python toolbox. Or you could embed this into another loop and do this on a ...
Evil Genius's user avatar
  • 6,221
6 votes
Accepted

Can a SHAPE field be non-nullable?

Yes and No. As @whyzar has answered, you can change the Allow NULL values property on the SHAPE field. However, this will not stop features being added without geometry! To emphasise the point at ...
Midavalo's user avatar
  • 29.5k
6 votes
Accepted

Representing NULL data for a numeric field in ArcGIS (symbology)

Create an exclusion in your symbol classification. In your Layer Properties > Symbology tab, click Classify. In the Classification dialog click Exclusion: On the Query tab, add an exclusion for ...
Midavalo's user avatar
  • 29.5k
6 votes

Use gdal to set multiband raster values to no data

The syntax is documented on the manual page https://www.gdal.org/gdalwarp.html as If more than one value is supplied all values should be quoted to keep them together as a single operating system ...
user30184's user avatar
  • 62k
6 votes

Hiding NULL text in attributes using QGIS?

From Settings -> Options -> Data Sources -> Delete NULL text: Before deletion: After deletion:
ahmadhanb's user avatar
  • 40.3k
6 votes

Changing 0 to NULL in QGIS Attribute table

After selecting the layer, use this script in the QGIS's Python Editor (Ctrl+Alt+P): from qgis.utils import iface layer = iface.activeLayer() idx = range(layer.fields().count()) layer.startEditing()...
Kadir Şahbaz's user avatar
6 votes
Accepted

Fill combobox with NULL values in PyQGIS

'NULL' is not different from any string. Instead, you should use NULL. Remove apostrophes. NULL is automatically imported in QGIS. Outside QGIS you need to import NULL. It is a PyQGIS variant, not ...
Kadir Şahbaz's user avatar
6 votes
Accepted

Concatenate multiple fields where some contain null values (QGIS)

First possibility: use concat and replace double commas where you have empty entries: replace( concat (field_a,', ',field_b,', ',field_c), ', ,', ',') Second possibility: use arrays to concatenate, ...
Babel's user avatar
  • 63.1k
6 votes
Accepted

Date coming through as NULL when data type is set to "date" in csv/t

Your date is not a date. It is a string representing a date. A date is in format yyyy-MM-dd. You can convert it to a date once you loaded your data as string, e.g. by adding a virtual field via field ...
MrXsquared's user avatar
  • 32.6k
6 votes

Deleting contents of all entries in field in QGIS Attribute table

After selecting the layer, use this script in the Python Editor of QGIS: layer = iface.activeLayer() # make a dictionary for indexed NULL value null_attr = {i: NULL for i in range(layer.fields()....
Kadir Şahbaz's user avatar
6 votes

Deleting NULL geometries and duplicate nodes from table using PostGIS

This requires a procedural execution of dynamic SQL - best applied with a DO block. Since we are only looking at modifying columns of type GEOMETRY, we can identify the respective relations easily ...
geozelot's user avatar
  • 28.8k
5 votes
Accepted

Using Null values in Field Calculator

You can create a list and check if your value exists in that list. Place your possible Null/empty/spaced values into that list and check them all at once. def findnulls(fieldname): if rec_a in [...
Midavalo's user avatar
  • 29.5k
5 votes
Accepted

ArcMap Field Calculator Remove Null values

Im sure this is Python and not VB script. By putting the 0 in speech marks, you are trying to say that 0 is a string, when its not. As added by Martin, please select the Python Parser instead of the ...
MacroZED's user avatar
  • 2,281

Only top scored, non community-wiki answers of a minimum length are eligible