PostGis:几何类型(LineString)与列类型(多边形)不匹配

时间:2020-07-09 08:15:51

标签: postgresql postgis

在这种情况下,我有点迷茫。

让我解释一下:我目前正在对表进行查询,很奇怪我收到了这个错误

sqlalchemy.exc.DataError: (psycopg2.errors.InvalidParameterValue) Geometry type (LineString) does not match column type (Polygon)

但是,我的表和她的数据中不应该包含LineString元素(但是,数据不是由我生成的,因此可能有错误)。 因此,我不知道如何找到导致这种情况的坏男孩或如何对待它。

他来自的表数据具有这种结构(我们称为table_1):

created_on         |         updated_on         |   id  | polygon 

新表格数据(我们称为table_2):

created_on         |         updated_on         |   id  | polygon 

要检查数据之一是否为LineString,请尝试以下查询:

SELECT count(id)  FROM table_1 WHERE ST_GeometryType(polygon::geometry)='ST_LineString';
 count
-------
     0
(1 row)

并且确保我对应该存在的逻辑几何执行相同的查询,并且得到了:

SELECT count(id)  from table_1 WHERE ST_GeometryType(polygon::geometry)='ST_Polygon';
 count
-------
  5191
(1 row)
SELECT count(*)  from table_1 ;
 count
-------
  5191
(1 row)

所以我有点迷路,感谢大家的帮助 如果我犯了一个愚蠢的错误,请告诉我哈哈

0 个答案:

没有答案