[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    Re: [postgis-users] Is there a function to detect potential enclosure rather than ST_IsClosed() exac
From:       Marcin Mionskowski <mionskowskimarcin () gmail ! com>
Date:       2022-02-16 20:14:43
Message-ID: CAH_vRsGNa7Qnuia11rFLDB4rThEc3njbqydJQfPO-xdQ8BxL-Q () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

=C5=9Br., 16 lut 2022 o 17:31 Shaozhong SHI <shishaozhong@gmail.com> napisa=
=C5=82(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@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
>

[Attachment #5 (text/html)]

<div dir="ltr"><div class="gmail_default" style="font-family:monospace">I think you \
will find the answer yourself when you define what &quot;lines may resemble \
enclosures&quot; 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))&lt;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))&lt;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 \
&quot;somevalue&quot; 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 &lt;<a \
href="mailto:shishaozhong@gmail.com">shishaozhong@gmail.com</a>&gt; \
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>



_______________________________________________
postgis-users mailing list
postgis-users@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic