I’ve to create a spatial intersection of two tables (poly_a and poly_b) containing polygon features. Is there any way to remove unexpected linestring results?
CREATE VIEW poly_intersection AS SELECT
row_number() over() AS gid,
subquery.*
FROM
(SELECT
(ST_Dump(ST_Intersection(poly_a.geom, poly_b.geom))).geom::geometry(polygon, 4326)
FROM poly_a, poly_b
WHERE ST_Intersects(poly_a.geom, poly_b.geom) AND NOT ST_Touches(poly_a.geom, poly_b.geom)
) AS subquery;
ERROR: Geometry type (LineString) does not match column type (Polygon)
I’m wondering about the line geometries because of using AND NOT ST_Touches(poly_a.geom, poly_b.geom)
in the WHERE
clause.