从 varchar (x,y) 创建点几何图形

发布于 2025-01-13 05:31:16 字数 248 浏览 2 评论 0原文

我有一张很大的位置表。这些位置采用 varchar 格式,写为 (x,y)。我需要为所有位置创建一个单独的点。我已在表中创建了一个点几何列,但无法弄清楚如何根据位置所在的格式为位置创建点。

地理数据坐标位于 (x,y) 的单列中 例如(52.3852758,4.8682022)

我正在使用此脚本但出现错误。

更新“tlblocation”设置 geom=ST_GeomFromText(geodata);

任何帮助将不胜感激

I have a large table of locations. The locations are in varchar written as (x,y). I need to create a individual point for all of the locations. I have created a point geometry column in the table but can't figure how to create points for the locations from the format that they are in.

geodata coordinates are in a single column of (x,y)
e.g (52.3852758,4.8682022)

I am using this script but getting error.

update "tlblocation" set geom=ST_GeomFromText(geodata);

Any help would be much appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

游魂 2025-01-20 05:31:16

您可以使用 ST_* 函数。 IE:

drop table if exists geosample;
CREATE TABLE geosample(gid serial PRIMARY KEY,  geog geography(POINT) null, pointAsVarchar varchar(100));

insert into geoSample (pointAsVarchar) values
('(-74.06414465351811,40.70677298472955)'),
('(-122.33383026916862,47.62266259856472)'),
('(2.3501235468097144,48.86267330918897)');


update geoSample set geog = st_pointfromtext('POINT'||replace(pointAsVarchar,',',' ')) where 1=1;

select *, st_astext(geog) from geosample;

You can use ST_* functions. ie:

drop table if exists geosample;
CREATE TABLE geosample(gid serial PRIMARY KEY,  geog geography(POINT) null, pointAsVarchar varchar(100));

insert into geoSample (pointAsVarchar) values
('(-74.06414465351811,40.70677298472955)'),
('(-122.33383026916862,47.62266259856472)'),
('(2.3501235468097144,48.86267330918897)');


update geoSample set geog = st_pointfromtext('POINT'||replace(pointAsVarchar,',',' ')) where 1=1;

select *, st_astext(geog) from geosample;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文