To remove duplicate lists from a list, there are several nice ways in Python - for example:
a = [[ 9.1514622, 47.1166004 ], [ 9.1513045, 47.1164599 ], [ 9.1516278, 47.1163001 ], [ 9.1517832, 47.1164408 ], [ 9.1514622, 47.1166004 ] ]
print len(a) # 5
b_set = set(map(tuple,a))
b = map(list,b_set)
print len(b) # 4
But unfortunately, I had to convert my list to a Shapely Polygon object, in which I need to simplify the geometry and do some other geo functions.
from shapely.geometry import Polygon
a = [[[ 9.1514622, 47.1166004 ], [ 9.1513045, 47.1164599 ], [ 9.1516278, 47.1163001 ], [ 9.1517832, 47.1164408 ], [ 9.1514622, 47.1166004 ] ] ]
polys = [Polygon(item) for item in a] # convert list to polygon
print len(polys) # prints 5
This answer shows how to remove a duplicate Polygon from a list of Polygons, but how can I remove a duplicate point from a list of points, as a Shapely polygon?
I guess it's possible to convert it back to a list, remove duplicates, and then re-convert to Polygon.
But that seems overly complicated. Any ideas on how to do this?