QGIS 3.4x64 and Python 3.7 seem to sometimes treat my geometries as equal, sometimes not.

I'm debugging code using a reduced dataset with 3 points. Points A and B have the same geometry, and point C is different. I verified this using geometry.isEqual().

I need a dictionary with the format { geometry : [point_ids] }, where the key is the geometry of a point, and the value is a list of all points with that geometry.

When I run the following code, my dictionary should be { geomA : [A, B], geomC : [C] }.

reverse_geoms.setdefault(g, list()).append(v)

Instead, I get { gA : [A], gB : [B], gC : [C] }.

So this means that I have a duplicate key, because gA == gB. Or, it means the geometries aren't actually equal, but I checked and I believe they are. Is there something wrong with my code, or am I misunderstanding something about geometries?


Your Answer

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

Browse other questions tagged or ask your own question.