My question is: If number of nodes in both geometries are same and coordinates are also same (ordering of coordinates might different), can I conclude that both geometries are same?
I have two sets of coordinates (X and Y) of a geometry. I have counted number of nodes available in both geometries and also have coordinates.
I checked whether second geometry coordinates are all available in first cooridnates or not using below line of code and as a result, I got 'Yes'
.
new_coordi1 = [(0.26, 0.27), (0.56, 1.22), (1.51, 0.93), (1.21, -0.03), (0.92, -0.98), (1.87, -1.28), (2.17, -0.33), (2.47, 0.63), (-0.04, -0.69), (-0.34, -1.64), (-1.29, -1.34), (-0.99, -0.39), (-0.7, 0.57), (-1.65, 0.86), (-1.95, -0.09), (-2.25, -1.05), (-1.35, 1.82), (-0.4, 1.52)]
new_coordi2 = [(0.26, 0.27), (0.56, 1.22), (1.51, 0.93), (1.21, -0.03), (0.92, -0.98), (1.87, -1.28), (2.17, -0.33), (2.47, 0.63), (-0.04, -0.69), (-0.99, -0.39), (-1.29, -1.34), (-0.34, -1.64), (-2.25, -1.05), (-1.95, -0.09), (-1.65, 0.86), (-0.7, 0.57), (-0.4, 1.52), (-1.35, 1.82)]
check = all(item in new_coordi2 for item in new_coordi1)
Background of this Question: I have two geometries. These geometries are same and they were oriented in the different way in 2D space. I aligned them using Principal Component Analysis and place both geometries at the common orientation. I want to confirm whether two geometries are same or not.
I think this approach works.
new_coordd1 = sorted(new_coordi1 , key=lambda tup: (tup[0],tup[1]) )
new_coordd2 = sorted(new_coordi2 , key=lambda tupp: (tupp[0],tupp[1]) )
new_coordd1 == new_coordd2
>>> True