1

I'm using PostGIS 2.5.2 on PostgreSQL 10, and I'm trying to build a function which would split a LineString into portions, depending on points positionned close to it. I'm getting a Geometry type (Point) does not match column type (LineString) error, and I can't figure out why. I've stumbled upon this old answer but it's not helping me. Here's where the error comes from :

INSERT INTO portions_lignes(id_parcours, ordre_portion_parcours, id_arret, geom) 
VALUES(line_id, prior_point.ordre_arret_parcours, prior_point.id_arret, ST_LineSubstring(linestring, 0, ST_LineLocatePoint(linestring, current_point.geom) / 2));

Where portions_lignes.geom is a LineString geometry type, linestring is also a LineString, and current_point.geom is a Point geometry type.

All geometry types are in SRID 4326, my goal here is just to insert into portions_lignes a particular line_substring (using ST_LineSubstring) from the linestring parameter, which is passed to the function and declared like this :

CREATE OR REPLACE FUNCTION splitLine(
    line_id character varying,
    linestring geometry(LineString,4326)
)
2
  • when ST_LineLocatePoint ... returns 0 as endfraction (i.e. closest point is the start point), ST_LineSubstring returns a POINT.
    – geozelot
    Commented May 6, 2019 at 10:58
  • @ThingumaBob Thanks for your answer, I just noticed that in the ST_LineSubstring documentation.
    – Adrien
    Commented May 6, 2019 at 11:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.