如何将空间数据插入到包含road列的表中

68bkxrlz  于 2021-06-17  发布在  Mysql
关注(0)|答案(1)|浏览(345)

当我试图使用路段之间点的坐标将数据插入线表时,收到此错误消息。

ERROR:  parse error - invalid geometry
HINT:  "SRID=27700;LINESTRING((5" <-- parse error at position 24 within geometry
SQL state: XX000

我的部分代码:

NSERT INTO public."RoadSegments"("no", "seg_ID", "description", "location", "length", "the_geom")
VALUES 

(1,'Seg_1','Shephards Bush to Royal Crescent','Shephards Bush','540',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.504593 -0.220437),(51.505233 -0.214105))')),
(2,'Seg_2','Royal Crescent to Norland Square','Notting Hill','306',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.505233 -0.214105),(51.506053 -0.209956))')),
(3,'Seg_3','Norland Square to Holland Park','Notting Hill','383',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.506053 -0.209956),(51.507575 -0.204795))')),
(4,'Seg_4','Holland Park to Notting Hill Gate','Notting Hill','477',ST_GeomFromEWKT('SRID=27700;LINESTRING((51.507575 -0.204795),(51
64jmpszr

64jmpszr1#

您的linestring参数中似乎有太多的括号。请尝试以下操作:

INSERT INTO public."RoadSegments"("no", "seg_ID", "description", "location", "length", "the_geom")
VALUES 

(1,'Seg_1','Shephards Bush to Royal Crescent', 'Shephards Bush','540',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.504593 -0.220437,51.505233 -0.214105)')),
(2,'Seg_2','Royal Crescent to Norland Square', 'Notting Hill',  '306',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.505233 -0.214105,51.506053 -0.209956)')),
(3,'Seg_3','Norland Square to Holland Park',   'Notting Hill',  '383',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.506053 -0.209956,51.507575 -0.204795)')),
(4,'Seg_4','Holland Park to Notting Hill Gate','Notting Hill',  '477',ST_GeomFromEWKT('SRID=27700;LINESTRING(51.507575 -0.204795,51 ...              '))

这应该是正确的语法(坐标周围没有额外的括号)

相关问题