0

I have two geometries, one is Line Other one is Point.

I tried find intersects between features

QgsGeometry(point).intersects(QgsGeometry(line))

I have two cases:

case1: if point placed on line vertices

In this case its return True

case2: if point placed on line edge (no vertex under point)

Iin this case its return False

point line

I tried intersects,touches,within,contains,overlaps all these are returning False.

Why?

3
  • 1
    Are you sure they are on top? line1.distance(point1)
    – BERA
    Jan 4, 2022 at 12:48
  • i checked distance its give 1.1 but physically its intersected Jan 4, 2022 at 12:49
  • 4
    Point on line is sometimes impossible to detect in binary computers, because the point of intersection can't be represented as an IEEE Floating-point value. This is the same basic issue of why you should never do exact real value comparison. You always want to test distance less than a threshold.
    – Vince
    Jan 4, 2022 at 13:43

1 Answer 1

4

A point has no 2D area or "range" so if there is a distance between it and another geometry, they are disjunct. A point has to lie exactly on the line for any of the geometry predicates you mention to evaluate to True.

As you mention in your comment, there is a distance of >0 between your point and the line so they do not intersect.

The image you posted is a graphical representation where the line and point are both shown with some width so we can see them. In the geometric model the line actually has a width of zero and the point an area of zero.

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.