3

According to this link, ST_IsValid should return self-intersections.

However, using the following WKT, I get that the following line is valid:

SELECT ST_IsValid(ST_GeomFromText('MultiLineString ((8.02023999999999937 48.59458999999999662, 8.02011000000000074 48.5946700000000007, 8.01928000000000019 48.59503999999999735, 8.01782000000000039 48.59566999999999837, 8.01661000000000001 48.59620000000000317, 8.01540999999999926 48.59669000000000239, 8.01399999999999935 48.59727000000000174, 8.01403999999999961 48.59732999999999947, 8.01404999999999923 48.59734999999999872, 8.01402999999999999 48.59736999999999796, 8.01295000000000002 48.59783999999999793),(8.01295000000000002 48.59783999999999793, 8.01243999999999978 48.59805999999999671, 8.01239999999999952 48.59805999999999671, 8.01238000000000028 48.59803999999999746, 8.01226999999999911 48.59790999999999883, 8.01272999999999946 48.59765999999999764, 8.01290000000000013 48.59779999999999944, 8.01295000000000002 48.59783999999999793),(8.01295000000000002 48.59783999999999793, 8.01309999999999967 48.59794999999999732, 8.01324999999999932 48.59806999999999988, 8.0135500000000004 48.59828999999999866, 8.01423999999999914 48.5988400000000027, 8.01464999999999961 48.59917000000000087, 8.01477000000000039 48.59929000000000343, 8.01481000000000066 48.5993700000000004))', 4326));

Here is a visualization of the line, the green icon pointing out the self-intersection:

enter image description here

What am I missing?

4
  • 1
    it's only for polygon border Aug 24, 2023 at 15:42
  • 2
    You need st_issimple
    – jbalk
    Aug 24, 2023 at 17:58
  • 1
    Also you are working with a multiline and the intersection point is the start or end node of every part. None of the individual segment is crossing itself
    – JGH
    Aug 24, 2023 at 19:51
  • Thank you. This helped me find this: gis.stackexchange.com/questions/367120/… Unfortunately the answer is not as simple as it should be. Aug 25, 2023 at 6:56

1 Answer 1

5

A line crossing itself is not invalid.

Take a look at 4.4. Geometry Validation

For linear geometry the only validity rule is that LINESTRINGs must have at least two points and have non-zero length (or equivalently, have at least two distinct points.) Note that non-simple (self-intersecting) lines are valid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.