2

I have two LineString and I want take their intersection. I don't understand why PostGIS doesn't give me the correct answer.

select ST_Intersection(st_geomfromtext('LINESTRING(2.9363672 36.769075,2.9364605 36.7688602,2.9368677 36.7673497,2.937295 36.7665308,2.93756649563816 36.7660571843283)', 4326), 
                   st_geomfromtext('LINESTRING(2.93667144830571 36.7680776916115,2.9368677 36.7673497,2.937295 36.7665308,2.9377967 36.7656556)', 4326))

It's clear that the real intersection is not what gives PostGIS.

4
  • 1
    What do you get and what do you suppose to get?
    – user30184
    Apr 3, 2021 at 11:43
  • It give me small part of real intersection. You can test it and see. Apr 3, 2021 at 12:58
  • Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Apr 3, 2021 at 13:06
  • Thank you, But I think having problem with one function in postgis, this is why I asked for it. Apr 3, 2021 at 13:52

1 Answer 1

3

Finally, I find the solution. Before comparing geometries in PostGIS, we must put them in same plan with "st_snap". Then, my query must be like this :

select ST_Intersection(
   st_snap(st_geomfromtext('LINESTRING(2.9363672 36.769075,2.9364605 36.7688602,2.9368677 36.7673497,2.937295 36.7665308,2.93756649563816 36.7660571843283)', 4326), 
           st_geomfromtext('LINESTRING(2.93667144830571 36.7680776916115,2.9368677 36.7673497,2.937295 36.7665308,2.9377967 36.7656556)',4326),0.0000001),
   st_geomfromtext('LINESTRING(2.93667144830571 36.7680776916115,2.9368677 36.7673497,2.937295 36.7665308,2.9377967 36.7656556)', 4326))

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.