Is it normal to use the geometry type 'multipoint' instead of 'point' knowing that I use it to store only one point?
How can I convert from multipoint to point?
Is it normal to use the geometry type 'multipoint' instead of 'point' knowing that I use it to store only one point?
How can I convert from multipoint to point?
To convert "Multipoint" to "Point", you have to use ST_Dump, for example:
SELECT (ST_Dump(the_geom)).geom AS the_POINT_geom
FROM MULTIPOINT_table;
On the question of using "Multi" or single geometries, I use this logic:
The easiest way to extract a point from a single-point MULTIPOINT
is ST_GeometryN
:
SELECT ST_AsText(ST_GeometryN('MULTIPOINT ((1 1))', 1));
--POINT(1 1)
This avoids potential problems in situations where a set-returning function cannot be used.
There are some important optimizations that are available only to POINT
type geometries (especially in earlier versions of PostGIS), so storing single points as POINT
is good practice. A POINT
also uses about 25% less space than a MULTIPOINT
.