I have two points:
a=QgsGeometry.fromPoint(QgsPoint(227739,908343))
b=QgsGeometry.fromPoint(QgsPoint(227739,908343))
but when I run:
a==b
it returns False. What am I doing wrong?
Update:
it returns True when I only use:
a=(QgsPoint(227739,908343))
b=(QgsPoint(227739,908343))
Answer
Instead of using ==, just use the following command:
a=QgsGeometry.fromPoint(QgsPoint(227739,908343))
b=QgsGeometry.fromPoint(QgsPoint(227739,908343))
a.equals(b) # -> returns True
EDIT:
Regarding to the comments on this answer:
a = QgsPoint(227739,908343)
b = QgsPoint(227739,908343)
a == b # TRUE
aa = QgsGeometry.fromPoint(a)
bb = QgsGeometry.fromPoint(b)
aa.equals(bb) # TRUE
Try to investigate the type of your points (are they really QgsPoints?) and if it still doesn't work, than compare the values manually
a.x() == b.x()
No comments:
Post a Comment