[postgis-users] Is there a function to detect potential enclosure rather than ST_IsClosed() exact?

Marcin Mionskowski mionskowskimarcin at gmail.com
Wed Feb 16 12:14:43 PST 2022


I think you will find the answer yourself when you define what "lines may
resemble enclosures" mean :)
For example, you can SELECT * FROM table_with_linestrings WHERE NOT
ST_IsClosed(geom) and ST_Distance(ST_StartPoint(geom),
ST_EndPoint(geom))<somevalue;
You can try to optimize performance by replacing:
- ST_IsClosed(geom) with ST_Equals(ST_StartPoint(geom),ST_EndPoint(geom)),
- ST_Distance(ST_StartPoint(geom),ST_EndPoint(geom))<somevalue with
ST_DWithin(ST_StartPoint(geom),ST_EndPoint(geom)),somevalue).
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.

śr., 16 lut 2022 o 17:31 Shaozhong SHI <shishaozhong at gmail.com> napisał(a):

> ST_IsClosed can detect a closed polygon.
>
> But, sometime, lines may resemble enclosures but not closed.  Can such
> lines be detected?
>
> Regards,
>
> David
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20220216/84abafaf/attachment.html>


More information about the postgis-users mailing list