1

Does anyone know how to create points along a line (MultiLineString geometry) with a given distance in PostGIS? I'd like to create points at a regular distance over a line, which represents a shoreline.

2

Use ST_Line_Interpolate_Point

union them first to create a single complete without gaps line .

1

This worked:

CREATE TABLE coastalsegments AS (SELECT ST_Line_Substring(the_geom, 1000.00*n/length,
   CASE WHEN 1000.00*(n+1) < length THEN 1000.00*(n+1)/length ELSE 1 END) As the_geom
FROM
  (SELECT ST_LineMerge(coastal_shoreline.geom) AS the_geom, ST_Length(coastal_shoreline.geom) As length
   FROM coastal_shoreline)
   ) AS t
CROSS JOIN generate_series(0,10000) AS n
WHERE n*1000.00/length < 1);

ALTER TABLE coastalsegments ADD id bigserial, ADD segm_length real;

UPDATE coastalsegments SET segm_length = ST_Length(the_geom);

CREATE TABLE coastal_pts AS SELECT id, ST_Line_Interpolate_Point(the_geom, 0.5) AS the_geom FROM  coastalsegments;
  • This should probably be made into an edit ("added solution") to your original post, and accept nicves's answer. – Simbamangu May 18 '16 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.