I have made a buffer on the area shown. If you closely in zoom there is a line beneath the buffer. I am using ST_Within for the comparison. There are two linestrings in my area. I am making buffer of about 10 meters on one area and comparing it with the other linestring using ST_WITHIN. The linestring is divided into different segments. ST_Within checks that two geometries should be completely inside. If you can see closely in the picture I only want the linestring which is inside the buffer but ST_within ignores the complete segment because small portion of line is outside buffer and Moreover, I also dont want this extra line which is outside buffer. Is there a way to compare these lines so that I can get only that segment which is inside buffer?. I cannot use ST_Intersects because then I will have other extra intersecting lines as well which I dont want. Here is my query:
Create Table CombinedTable As select area1.Geometry AS Geometry from Area1 area1,Area2 area2 where
St_Within(area2.geom,ST_Buffer(SetSrid(area1.geometry,3857),10))