Reputation: 5506
I have two columns column1, column2 that are curently type of real and I want to combine them in order to get a geometry(Point,4326). My current code is this one:
INSERT INTO table2(location)
SELECT
geometry(POINT(column1, column2))
FROM
table1
I get this error: Geometry SRID (0) does not match column SRID (4326)
When I try to add the SRID in my geometry: geometry(POINT(column1, column2),4326)
it doesnt recognize geometry, throwing error: function geometry(point, integer) does not exist
Note that location is type of geometry(POINT, 4326)
. I have also tried UpdateGeometrySRID: select UpdateGeometrySRID('public', 'table2', 'location', 4326) ;
but i still get the same errors in both cases.
Any ideas?
Upvotes: 0
Views: 150
Reputation: 2436
This should work for you.
INSERT INTO table2(location)
SELECT
ST_SetSRID(ST_MakePoint(column1, column2), 4326);
FROM
table1;
Upvotes: 2