简体   繁体   English

POSTGIS:错误:对混合SRID几何进行操作。 尝试查找具有两个不同的SRIDS /表的重叠几何

[英]POSTGIS: ERROR: Operation on mixed SRID geometries. Trying to find overlapping geoms with two different SRIDS/tables

POSTGIS_VERSION=2.1; POSTGIS_VERSION = 2.1;

I have two tables with two different SRID. 我有两个带有两个不同SRID的表。 My objective is to show which geoms from TABLE_B intersect with a region from TABLE_A. 我的目标是显示TABLE_B中的哪些几何与TABLE_A中的区域相交。

SELECT tablebname, a.geom FROM TABLE_B as a INNER JOIN (SELECT geom FROM TABLE_A WHERE tableAID = '00001') as b ON ST_Intersects(a.geom, b.geom);

My table structure (truncated) is as follows 我的表结构(被截断)如下

TABLE_A TABLE_A
text tableAid 文字表帮助
geometry geom (SRID=3577) 几何几何(SRID = 3577)

TABLE_B TABLE_B
text tableBid 文字表格出价
geometry geom (SRID=4326) 几何几何(SRID = 4326)

I have tried transforming the geoms with ST_TRANSFORM(geom, 3577) but I still get the same error "ERROR: Operation on mixed SRID geometries." 我尝试使用ST_TRANSFORM(geom,3577)转换几何,但仍然收到相同的错误“错误:对混合SRID几何进行操作”。

Using the following command 使用以下命令
select distinct(ST_SRID(geom)) as srid, count(*) from tableA group by srid;

I get the following 我得到以下

srid | count
3566 | 2196
     |   18

My attempts at changing the last 18 to 3577 are futile. 我将最后18个更改为3577的尝试是徒劳的。 Each time I update the SRID it says it succeeded or did not find any SRID <> 3577. 每次更新SRID时,都会说它成功或未找到任何SRID <> 3577。

Any help would be appriciated. 任何帮助将被申请。 I can provided more details in required. 我可以根据需要提供更多详细信息。 Thanks. 谢谢。

Without a subquery, correcting the table alias, and using a transform, does this work? 如果没有子查询,更正表别名并使用转换,这行得通吗?

SELECT b.*, a.*
FROM table_b AS b
INNER JOIN table_a AS a ON
  tableaid = '00001' AND ST_Intersects(ST_Transform(a.geom, 4326), b.geom);

Also note that in your original query, you confuse TABLE_B as a , which possibly explains why your attempt with ST_Transform failed, since it wasn't transforming the intended a.geom column. 还要注意,在您的原始查询中,您将TABLE_B as a混淆TABLE_B as a ,这可能解释了您尝试使用ST_Transform失败的原因,因为它没有转换预期的a.geom列。 Furthermore, there is no such version of PostGIS 9.1, so I'm guessing you have 2.x. 此外,没有这样的PostGIS 9.1版本,所以我猜您有2.x。 If setup using typmods (eg, geometry(Polygon, 4326) ), these cannot have mixed SRIDs. 如果使用typmods进行设置(例如geometry(Polygon, 4326) ),则它们不能具有混合SRID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM