Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将2列合并为1,PostgreSQL_Sql_Postgresql_Geometry_Gis_Point - Fatal编程技术网

将2列合并为1,PostgreSQL

将2列合并为1,PostgreSQL,sql,postgresql,geometry,gis,point,Sql,Postgresql,Geometry,Gis,Point,我有两列column1和column2,它们现在是实数类型,我想将它们组合起来,以得到一个几何体(点4326)。 我目前的代码是: INSERT INTO table2(location) SELECT geometry(POINT(column1, column2)) FROM table1 我收到此错误:Geometry SRID(0)与列SRID(4326)不匹配。 当我尝试在几何体中添加SRID时:几何体(点(第1列,第2列),4326)它无法识别几何体,抛出错误:函数

我有两列column1和column2,它们现在是实数类型,我想将它们组合起来,以得到一个几何体(点4326)。 我目前的代码是:

INSERT INTO table2(location)
SELECT
    geometry(POINT(column1, column2))
FROM
    table1
我收到此错误:
Geometry SRID(0)与列SRID(4326)不匹配。

当我尝试在几何体中添加SRID时:
几何体(点(第1列,第2列),4326)
它无法识别几何体,抛出错误:
函数几何体(点,整数)不存在

请注意,位置为
几何体类型(点,4326)
。我还尝试过updategeMetricySrid:
select updategeMetricysrid('public','table2',location',4326)但是在这两种情况下我仍然得到相同的错误


有什么想法吗?

这应该适合你

INSERT INTO table2(location)
SELECT
    ST_SetSRID(ST_MakePoint(column1, column2), 4326);
FROM
    table1;

太棒了,谢谢你!没有注意到文档中的ST_SetGrid函数!