<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Sort of ugly but…<div><br></div><div>CREATE TEMPORARY TABLE p_edges AS</div><div> SELECT <a href="http://p.id">p.id</a>,</div><div> st_subdivide((st_dumprings((st_dump(geom)).geom)).geom) as geom</div><div> FROM p;</div><div><br></div><div>CREATE INDEX p_edges_geom_x ON p_edges USING GIST (geom);</div><div><br></div><div>SELECT <a href="http://a.id">a.id</a>, p.id</div><div> FROM a </div><div> JOIN p_edges ON ST_Intersects(a.geom, p_edges.geom)</div><div><div><br></div><div>Dump P multipolygon to polygon, polygon to rings, subdivide rings into shorter edges, find all members of A that intersect those edges.</div><div><br></div><div><br></div><div><br><blockquote type="cite"><div>On Dec 5, 2023, at 2:21 PM, Mats Taraldsvik via postgis-users <postgis-users@lists.osgeo.org> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div>Hi,</div><div><br></div><div>I have a large polygon P in a query against a table A where I'm only interested in A's polygons that touch/crosses the boundary of P.</div><div><br></div><div>I have tried <a href="https://postgis.net/docs/ST_DumpSegments.html">https://postgis.net/docs/ST_DumpSegments.html</a> but it does generate a lot of geometries when the polygon has 100s or 1000s of points.</div><div><br></div><div>Are there more efficient approaches to this?</div><div><br></div><div>Regards,</div><div>Mats Taraldsvik<br></div></div>
_______________________________________________<br>postgis-users mailing list<br>postgis-users@lists.osgeo.org<br>https://lists.osgeo.org/mailman/listinfo/postgis-users<br></div></blockquote></div><br></div></body></html>