ST_IsEmpty

ST_IsEmpty takes a geometry as an input parameter and returns 1 if the given geometry is empty. Otherwise 0 (zero) is returned.

A geometry is empty if it does not have any points that define it.

If the given geometry is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_IsEmpty(geometry)

Parameter

geometry
A value of one of the seven distinct spatial data types that represents the geometry that is to be tested.

Return type

INTEGER

Example

The following example creates three geometries, and then determines if the geometries are empty.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_geoms (id INTEGER, geometry ST_Geometry)

INSERT INTO sample_geoms VALUES
       (1, ST_Geometry(ST_Point('point EMPTY',0)))

INSERT INTO sample_geoms VALUES
       (2, ST_Geometry(ST_Polygon('polygon((40 120, 90 120, 90 150, 
       40 150, 40 120))' ,0)))

INSERT INTO sample_geoms VALUES
       (3, ST_Geometry(ST_MultiPoint('multipoint m (10 10 5, 50 10 6, 
       10 30 8)' ,0)))

INSERT INTO sample_geoms VALUES
       (4, ST_Geometry(ST_LineString('linestring z (10 10 166, 
       20 10 168)',0)))

INSERT INTO sample_geoms VALUES
       (5, ST_Geometry(ST_Point('point zm (10 10 16 30)' ,0)))




SELECT id, ST_IsEmpty(geometry)  Is_Empty
FROM sample_geoms

Results:

ID          IS_EMPTY
----------- -----------
          1           1
          2           0
          3           0
          4           0
          5           0