I'm trying to snap a line theme to a point theme using PostGIS with a filter so they only snap to records with the same reference number. The query I'm using is as follows (this is a sample of the data and without the query, just trying to get the snapping working!)

CREATE TABLE public.snappedfeatures3mV13_TABLE AS
    st_snap(featuresshape_cut.geom, "nodes_cut ".geom, 2::double  precision) AS geom,
    featuresshape_cut.id ,    
FROM featuresshape_cut
JOIN "nodes_cut " ON featuresshape_cut.site_code::text = "nodes_cut ".site_code::text

No errors received, seems to generate the output file fine, however the output is multiple features linking a snapped point and the two closest points, image below. Green dots are the features snapped too, the black line the original and red is the output with arrows to indicate ends of line segments. Its almost like its calculating the snaps it needs to do then stopping?

Error received

I have

  • Converted the original features to be snapped to from lines to points - no effect
  • Cut the dataset down to a minimum
  • Checked all inputs have valid geometry
  • Generated new primary keys for all inputs
  • played with snapping tolerance to ensure snapping is working as expected
  • Checked all CRS are the same

No errors in PostGIS. I'm obviously missing something, what is it?

Demonstration of a single feature from the new file, there are 3 nodes in each record, the "middle" has snapped to the line as expected and the start and end are on nodes in the original line.

enter image description here

  • Is your linestring geometry (the original black one) just one continuous feature in the area you are showing, or is it comprised of several small ones? Is it Linestring, or Multilinestring? – Roberto Ribeiro Jan 26 '18 at 10:58
  • Isn't it just invalid geometry? seems like line is using the same nodes multiple times... like circle drawn few times using the same nodes. – Jendrusk Jan 26 '18 at 13:23
  • The original linestring is a single line, which shows as a valid geometry. – Ian Jan 26 '18 at 13:38
  • There are 3 nodes per feature, I have added an extra image in the original call to demonstrate a single feature. In each case 2 are on the original line and the "middle" one is snapped to where I want it to be. Geometry check says the file is fine for what its worth. – Ian Jan 26 '18 at 13:49
  • All lines are multiline, points are point – Ian Jan 26 '18 at 14:03

Your Answer

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

Browse other questions tagged or ask your own question.