ST_ToMultiPoint function
The ST_ToMultiPoint function takes a geometry as an input parameter and converts it to a multipoint. The resulting multipoint is represented in the spatial reference system of the specified geometry.
The specified geometry must be empty, a point, or a multipoint. If the specified geometry is null, then null is returned.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes that represents
the geometry that is converted to a multipoint.
A geometry can be converted to a multipoint if it is empty, a point, or a multipoint. If the conversion cannot be performed, then an exception condition is raised (SQLSTATE 38SUD).
Return type
ST_MultiPoint
Example
In the following example, the lines of results have been reformatted for readability. The spacing in your results will vary according to your online display
This example
illustrates the use of the ST_ToMultiPoint function.
CREATE TABLE sample_geometries (id INTEGER, geometry ST_Geometry)
INSERT INTO sample_geometries
VALUES (1, ST_Geometry ('multipoint (0 0, 0 4)', 1) ),
(2, ST_Geometry ('point (30 40)', 1) ),
(3, ST_Geometry ('multipolygon empty', 1) )
In the following SELECT statement, the ST_ToMultiPoint
function is used to return multipoints converted to ST_MultiPoint
from the static type of ST_Geometry.
SELECT CAST( ST_AsText( ST_ToMultiPoint(geometry))
AS VARCHAR(60) ) MULTIPOINTS
FROM sample_geometries
Results:
MULTIPOINTS
--------------------------------------------------------------
MULTIPOINT (0.000000 0.000000, 0.000000 4.000000)
MULTIPOINT (30.000000 40.000000)
MULTIPOINT EMPTY
