[postgis-users] Is there a generic function to find coincident vertex?

Shaozhong SHI shishaozhong at gmail.com
Thu Dec 2 16:34:20 PST 2021


Hip, Simon,
Many thanks.  I will try to test out soon.
I find postgis most amazing.
Regards, David

On Friday, 3 December 2021, Simon G Greener <simon at spatialdbadvisor.com>
wrote:

> Not that I am aware.
>
> You could try wrapping something like the following SQL in a function....
>
> with data as (
>     select 0.01 as tolerance,
>               ST_GeomFromText('LINESTRING(0 0 1.1,1 1.001 1.2,1 1.0005
> 1.3,1 1 1.1,2 2 1.2)',0) as geom
> )
> select SUM(isDuplicate) as duplicateCount
>   from (select case when ST_Distance(ST_PointN(a.geom,
> b.*),lead(ST_PointN(a.geom,b.*)) over (order by b.*)) < a.tolerance
>                     then 1
>                     else 0
>                 end as isDuplicate
>           from data as a,
>                generate_series(1,ST_NumPoints(a.geom),1) as b
>        ) as f;
>
> Note that if the linestring was a compoundCurve repeated vertices are part
> of the definition.
>
> regards
>
> Simon
> On 3/12/2021 9:46 am, Shaozhong SHI wrote:
>
> Is there a generic function to find coincident vertex and count?
>
>
> It will do the following:
>
>
> Create an array of all vertex present in a data set
>
> Iterate over and find out whether there be any coincident vertex as
> defined by a tolerance
>
> Count all occurrences
>
>
> Regards,
>
>
> David
>
> _______________________________________________
> postgis-users mailing listpostgis-users at lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/postgis-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211203/6e2c988c/attachment.html>


More information about the postgis-users mailing list