I have got area with line strings that are not quite similar to each other means that at some places they are not exactly at same position. This can be seen in the picture. I am making a buffer on linestring Area1 and then comparing it with the other linestring Area2. I am using ST_Intersection to get the intersection of buffer and linestring. As both areas are not located on each other so I have to increase the size of the buffer. There are also some extra linestrings in Area2 which I dont want. I only want the geometry of Area2 not Area1. My problem is that once I increase the size of buffer to get the intersection of both areas the extra lines in Area2 also comes in the geometry. I either want to remove these extra linestring from geometry or they should be compared in such a way that extra lines do not come from area2.

The first picture shows how area2 and area1 differs.

enter code here

The next pictures shows that If I increase the size of buffer it will include extraline which I dont want. The orange line is from Area2 and purple buffer is Area1 enter image description here

The query I am using is this in which I am getting the extra parts from AREA2 which I dont want.

Create Table Mytable As select
ST_MULTI(ST_Intersection(Area2,ST_Buffer(SetSrid(Area1.geometry,3857),8)))  AS Geometry
from Area2 ,Area1  where

I have tried everything but could not find the way.

Can Someone tell its not working? I have already tried ST_SNAP and ST_SNAPTOGRID but it is not working

  • I think what people normally do in these situations is use ST_SnapToGrid on all input points. However, if you want to modify only lines that potentially intersect, I think you'll have to use ST_Snap on the result of the buffered intersections. Even this may be weird on two lines that intersect in the middle. – Evan Carroll Sep 14 '17 at 15:25
  • Can you give an example. I am actually a newbie of these things so could not get what you said. How can we use ST_SNAPTOGRID? – mimetype Sep 14 '17 at 15:27
  • After you run all of the line points inside the line should lose precision and snap. Then they're all touching if they're within the specified tolerance. – Evan Carroll Sep 14 '17 at 15:39
  • Yes I have done it with ST_SNAP but the problem is that column returned contains 3 geometries named as Geometry collection, Multilinestring and multipoint – mimetype Sep 14 '17 at 15:42
  • Show a simplified dataset and your desired result. Preferably with WKT in the question. – Evan Carroll Sep 14 '17 at 15:42

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.