PostGIS Multipoint – How to Create Multipoint from Point

multipointpostgis

I am quite new to PostGIS.

I need take some points from an existing table and create a multipoint and save this.

How would i go about this?

The only way i can think without creating a new table is:

Alter table
alter column geom TYPE geometry (MULTIPOINT,3857) USING ST_Multi(geom);

if i had to create a table what would the statement look like when using the x,y of the points in the point table?

Ive been asked to then find the centre of the mutlipoint, I know i need to use ST_Centroid but what would the code look like?

Best Answer

If I understand you correctly you could do this:

CREATE TABLE point_union
AS(SELECT ST_Multi(ST_Union(geom))::geometry(MultiPoint, 3857) AS geom
FROM your_table);

CREATE TABLE center
AS(SELECT ST_Centroid(geom)
FROM point_union);

You then get a MultiPoint Layer point_union and a centroid layer center of point_union.

EDIT: To clarify my answer, from what you described, I assumed you might be better of using ST_Union.

Related Question