<div dir="ltr"><div class="gmail_default" style="font-family:monospace">I think you will find the answer yourself when you define what "lines may resemble enclosures" mean :)</div><div class="gmail_default" style="font-family:monospace">For example, <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>you can SELECT * FROM table_with_linestrings WHERE NOT ST_IsClosed(geom) and ST_Distance(<span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span></span></span></span>ST_StartPoint(geom),</span></span></span>ST_EndPoint(geom))<somevalue;</div><div class="gmail_default" style="font-family:monospace">You can try to optimize performance by replacing:<br></div><div class="gmail_default" style="font-family:monospace">- <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>ST_IsClosed(geom) with ST_Equals(<span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>ST_StartPoint(geom),</span></span></span>ST_EndPoint(geom)),</span></span></span></div><div class="gmail_default" style="font-family:monospace"><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>- <span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>ST_Distance(<span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span></span></span></span>ST_StartPoint(geom),</span></span></span>ST_EndPoint(geom))<somevalue with ST_DWithin(<span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>ST_StartPoint(geom),</span></span></span>ST_EndPoint(geom)),somevalue).<br></span></span></span></div><div class="gmail_default" style="font-family:monospace"><span class="gmail-VIiyi" lang="en"><span class="gmail-JLqJ4b gmail-ChMk0b gmail-C1N51c"><span>How to determine "somevalue" value is completely up to you - it can be a unit of your coordinate system, accuracy/precision of source data, a fraction of the minimum distance between the vertices of your lines  etc.<br></span></span></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">śr., 16 lut 2022 o 17:31 Shaozhong SHI <<a href="mailto:shishaozhong@gmail.com">shishaozhong@gmail.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">ST_IsClosed can detect a closed polygon.<div><br></div><div>But, sometime, lines may resemble enclosures but not closed.  Can such lines be detected?</div><div><br></div><div>Regards,</div><div><br></div><div>David</div></div>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
</blockquote></div>