I’m trying to export contours from contourf to geojson, the problem is that after generating the polygons, there are actually two lines on top of each other on each border.
The question is how to calculate the area of polygons and sort from the largest area to the smallest to create single polygons without double border lines.
poly_features = []
for col in t.collections:
for contour_path in col.get_paths():
for ncp,cp in enumerate(contour_path.to_polygons()):
x = cp[:,0]
y = cp[:,1]
new_shape = geometry.Polygon([(i[0], i[1]) for i in zip(x,y)])
if ncp == 0:
poly = new_shape
else:
poly = poly.difference(new_shape)
poly_features.append(Feature(geometry=poly))
feature_collection = FeatureCollection(poly_features)