如何将WKT(众所周知的文本)格式的带孔多边形插入postgis表中?

发布于 2024-08-17 18:52:06 字数 460 浏览 3 评论 0原文

我在postgis中有一个表,它有4列:ID、名称、the_geom、SRID。我需要编写一个 SQL 查询,它将将此外部多边形(元素 1)插入名为“woods”的表中,ID = 44,该外部多边形的名称为“oak”,SRID 为“4412”。

元素 1 和元素 2(孔)的坐标值: 元素 1= [P1(6,15)、P2(10,10)、P3(20,10)、P4(25,15)、P5(25,35)、P6(19,40)、 P7(11,40), P8(6,25), P1(6,15)] 元素 2= [H1(12,15), H2(15,24)]

这是图像: http://download.oracle.com/docs/html/A85337_01/sdo_objb。动图

I have a table in postgis, which has 4 columns: ID, name, the_geom, SRID. I need to write an SQL query which will insert this exterior polygon (Element 1) in the table named "woods", ID = 44, the name of that exterior polygon is "oak", and SRID is "4412".

The coordinate values for Element 1 and Element 2 (the hole):
Element 1= [P1(6,15), P2(10,10), P3(20,10), P4(25,15), P5(25,35), P6(19,40),
P7(11,40), P8(6,25), P1(6,15)]
Element 2= [H1(12,15), H2(15,24)]

Here is the image:
http://download.oracle.com/docs/html/A85337_01/sdo_objb.gif

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

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

发布评论

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

评论(2

謌踐踏愛綪 2024-08-24 18:52:06

替代解决方案是使用 几何构造函数 函数 ST_GeomFromText

INSERT INTO woods (ID, name, SRID, geom)
VALUES (44, 'oak', 4326,
ST_GeomFromText(
    'POLYGON((6 15, 10 10, 20 10, 25 15, 25 35, 19 40, 11 40, 6 25, 6 15))',
     4326))

其中 SRID 示例等于 EPSG:4326

Alternative solution is to use geometry constructor function ST_GeomFromText

INSERT INTO woods (ID, name, SRID, geom)
VALUES (44, 'oak', 4326,
ST_GeomFromText(
    'POLYGON((6 15, 10 10, 20 10, 25 15, 25 35, 19 40, 11 40, 6 25, 6 15))',
     4326))

with example of SRID equal to EPSG:4326

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