I have a list of Shapely polygons. From that list I want to extract only unique polygons removing the duplicates.
How to do it in a faster way? (My list contains thousands of polygons)
from shapely.geometry import Polygon
lists = [[(1,1),(2,2),(3,3),(4,4)], [(6,6),(7,7),(8,8),(9,9)], [(1,1),(2,2),(3,3),(4,4)]]
polys = [Polygon(item) for item in lists] ##This is given condition
for poly in polys:
test = [p.intersects(poly) for p in polys] ##Return true or false
print test
[True, False, True]
[False, True, False]
[True, False, True]
The expected result is:
[[(1,1),(2,2),(3,3),(4,4)], [(6,6),(7,7),(8,8),(9,9)]]