I have a PostGIS table of singlepart line segments that I've run the
ST_ChaikinSmoothing function on. Smoothing all of the line segments worked great, but these simplified geometries created small gaps between the other line segments in the table. (It's a network of flowlines) I need to snap the endpoints of each linestring to the closest segment of another line in the table.
I was directed to this answer about snapping lines, but I think it is snapping features in one layer (line) to features in another layer (input). I always struggle to comprehend PostGIS examples that use abstract text geometries in the queries as opposed to referencing tables of existing features.
My query below is returning an empty table with point geometry. I can successfully run each of these three functions individually to locate the points on the lines, but I can't figure out what i'm missing to snap the lines and create line geometries.
"geometry" is the name of my
geometry column in the
create table snapped_lines as ( SELECT ogc_fid, name, (ST_LineInterpolatePoint(geometry,ST_LineLocatePoint(geometry,ST_EndPoint(geometry)))) as geometry from smoothed_lines);
UPDATE: Sample dataset: https://www.dropbox.com/s/wz2265symhzsenl/smoothed_lines.pgsql?dl=0
The answer from @gabriel-de-luca below does snap the smoothed lines to the original lines based on matching id's, but
ST_Snap moves all vertices in a linestring, not just the end nodes and wrecks the smoothness of the input features.