我正在尝试使用PostGIS模板将一些数据输入到PostgreSQL 8.4数据库中。我无法UPDATE
多边形:
> 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
,但这不应该有所作为。
答案 0 :(得分:2)
您应该使用Geometry constructors在表格中加载新的几何图形,特别是St_GeomFromText函数:
UPDATE my_table SET box = ST_GeomFromText('POLYGON ((1 1), (2 3), (3 3), (1 1))');
几何体以WKT(Well-Known Text)格式定义。
答案 1 :(得分:1)
尝试:
UPDATE my_table SET box = '((1, 1), (2, 3), (3, 3), (1, 1))'::polygon;
据我所知,大多数几何类型一般都需要引号。