User Tools

Site Tools


Action disabled: revisions
gis:postgis

Add geometry with X,Y columns

ALTER TABLE your_table ADD COLUMN geom geometry(Point, 4326);
UPDATE your_table SET geom = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326);

Auto regenerate X,Y while inserting

PostgreSQL 12+

ALTER TABLE test ADD COLUMN geom geometry(Point,5514) GENERATED ALWAYS AS (ST_SetSRID(ST_MakePoint(jtsk_x, jtsk_y), 5514)) STORED
CREATE TABLE table(
    ...
    geom geometry(Point,4326) GENERATED ALWAYS AS (ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)) STORED
);
gis/postgis.txt · Last modified: 2021/11/09 13:06 by Jan Forman