TransWikia.com

How to extract a non contiguous multilinestring portion between 2 points?

Geographic Information Systems Asked on January 30, 2021

I have a non contiguous multilinestring.
I try to cut these multilinestring with points (see schema below)

I tried something like the code below, but the function St_LineSubString and ST_LineLocatePoint only work with linestring and do not work not with multilinestring…

How can I cut these non contiguous multilinestring?

extract_multilinestring

DECLARE
    r1 record; -- Roads table (1 multilinestring per road))
    r2 record; -- Points table
    p1 geometry; -- point
    p2 geometry;  --point
    res varchar;
BEGIN 
    FOR r1 in SELECT * FROM roads ORDER BY road_name ASC
    LOOP 
        p1=ST_StartPoint(r1.geom);
        FOR r2 IN SELECT * FROM points WHERE road_name = r1.road_name ORDER BY "PRD" ASC
        LOOP
            p2=r2.geom;
            SELECT ST_AsText(St_LineSubString(r1.geom,ST_LineLocatePoint(r1.geom,p1.geom),ST_LineLocatePoint(r1.geom,p2.geom))) INTO res;
            RAISE NOTICE '%',res;
            p1=p2;
        END LOOP;
    END LOOP;
END;

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP