1

enter image description hereI have a small road portion of a country in a form of linestrings. I want to compare it with the whole area of country(also linestrings) and get the features of the matching linestrings. The matching should be so exact that no extra points from whole country should appear in matching linestrings that does not appear to be in the small road portion. I have been comparing them with ST_intersect but the area I got contains some extra linestrings from the whole Area of country that are not in small portion of road. The techniques I have been reading suggests that I should be creating a some kind of a buffer to create the comparison. Somebody know an technique to get the exact comparison of these two linestring?. I have just started using POSTGIS so I am newbie.

The query I am using is this one but contains extra lines from WholeAreaTable which are not in SmallPortionTable

CREATE Table ExtraLineArea AS select id ,link.Geometry from WholeAreaTable WAT, SmallPortionTable SPT where 
ST_Intersects(WAT.Geometry,SPT.Geometry) 

I am selecting the id and geometry of WholeAreaTable when both geometries intersect. In the image brown line represents that intersecting area of both geometries. As WholeAreaTable contains all the geometries of country it is giving some extra line other then intersecting area which is purple line in the image(see on top of image single purple line).

I want comparison of WholeAreaTable and SmallPortionTable in such a way that this purple line should not appear in the final result.

  • Could you draw a sketch about what you want to achieve? – user30184 Sep 4 '17 at 14:38
  • Yeah sure I can – mimetype Sep 4 '17 at 14:39
  • @user30184 see the edited question – mimetype Sep 4 '17 at 14:57
  • For perfect vertex-by-vertex match I would use ST_Equals postgis.net/docs/ST_Equals.html. Or mayby ST_Covers postgis.net/docs/ST_Covers.html postgis.net/docs/ST_Covers.html if every vertex is not critical (vertices on the middle of a straight linestring which do not bend the line at all). – user30184 Sep 4 '17 at 15:15
  • Cannot use ST_Equals or ST_Cover because the points are not exactly equal to each other. The points are close to each other not have the same values – mimetype Sep 4 '17 at 15:20
1

These are the features which you first added into your question and then removed:

LINESTRING ZM(327909.497 6808438.915 90.416 0, 327911.946 6808439.106 90.341 2.4564, 327925.772 6808440.951 90.376 16.405, 327940.284 6808445.234 90.18 31.5358, 327951.206 6808449.346 90.282 43.2062, 327956.093 6808451.152 90.182 48.4163, 327961.349 6808451.138 89.898 53.6723, 327964.241 6808449.818 90 56.8513)

LINESTRING(327981.300935 6808365.031003, 327985.016518 6808372.66537, 327989.310438 6808385.47058, 327993.133348 6808398.916238, 327996.174084 6808410.698549, 327997.657363 6808418.929391, 327998.059613 6808425.623853, 327997.609842 6808433.239406, 327994.421005 6808440.092431, 327991.176344 6808443.450785, 327987.15875 6808445.332367, 327981.975209 6808445.775286, 327977.130078 6808444.892307, 327971.232208 6808442.864326, 327962.314799 6808440.573971, 327955.585748 6808437.708019, 327949.390128 6808437.284516, 327943.311077 6808440.85768, 327940.628234 6808445.778085, 327941.422165 6808452.041745, 327941.927263 6808456.636409, 327941.133349 6808463.27772, 327935.344827 6808472.914984)

Rip off Z and M off the first one and it becomes

LINESTRING(327909.497 6808438.915, 327911.946 6808439.106, 327925.772 6808440.951,327940.284 6808445.234, 327951.206 6808449.346, 327956.093 6808451.152, 327961.349 6808451.138,327964.241 6808449.818)

When these geometries are plotted on the map they look like this

enter image description here

I do not see much similarity.

  • You have made the correct drawing.These point is that what I am getting when I use ST_Intersect. I only have to get one point where they are intersecting. You can see that in the picture where they are intersecting. I want the comparison in that way that only intersecting point should be the result or may be I have to write an script to remove the unnecessary part and only keep the intersecting part – mimetype Sep 6 '17 at 8:22
  • According to your picture there is only one point where they match and I only want that point not all the linestring. May be I have to write some script to get rid of it – mimetype Sep 6 '17 at 8:23
  • one solution can be that to get all the unnecessary lines and remove it with some special function or script which I dont want – mimetype Sep 6 '17 at 8:27
  • I apologize but I just noticed that I do not understand your question and your aim at all. Does get the features of the matching linestrings mean vertices of the matching linestring? "Feature" in GIS means the whole object (point, line, polygon, geometry collection). – user30184 Sep 6 '17 at 8:31
  • Sorry, by feature means the attribute of the intersecting linestring in the above picture which is only one point not the whole linestring – mimetype Sep 6 '17 at 10:34

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.