我正在尝试使用 PostGIS 模板将一些数据输入到 PostgreSQL 8.4 数据库中。我无法更新
多边形:
> UPDATE my_table SET coords = POINT(1, 1)
UPDATE 0 1
> UPDATE my_table SET box = POLYGON(((1, 1), (2, 3), (3, 3), (1, 1)))
ERROR: function polygon(record) does not exist
> UPDATE my_table SET box = POLYGON((1, 1), (2, 3), (3, 3), (1, 1))
ERROR: function polygon(record, record, record, record) does not exist
> UPDATE my_table SET box = POLYGON(1, 1, 2, 3, 3, 3, 1, 1)
ERROR: function polygon(numeric, numeric, numeric, numeric, numeric, numeric, numeric, numeric) does not exist
> UPDATE my_table SET box = ((1, 1), (2, 3), (3, 3), (1, 1))
ERROR: column "box" is of type polygon but expression is of type record
如何插入多边形?请注意,数据已存在于表中,并且用 NULL
字段代替了空间数据。我需要 UPDATE
,而不是 INSERT
,但这不会有什么不同。
最佳答案
你应该使用 Geometry constructors在表中加载新几何图形,特别是 St_GeomFromText功能:
UPDATE my_table SET box = ST_GeomFromText('POLYGON ((1 1), (2 3), (3 3), (1 1))');
几何以 WKT ( Well-Known Text ) 格式定义。
关于sql - 为 PostGIS 编写原始 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3384527/