I have a table with 2400 polygons being a partition of a country at a low level. I have as well the population and the area for each polygon, giving me the density of each polygon.
I would like to make compact clusters of polygons to get nice-looking regions, based on the density.
Step 1, I took for each polygon the centroid then do a k-means with the coordinates of the centroids and the log of the density(as values could go from 0 to 400K).
The result is not resilient, as it depends a lot on the initial position of the points in the k-means algorithm and the result is not compact.
I am looking for another approach to this problem, which could solve my issues, aka:
Clusters are not resilient
Clusters are not compact
Clusters should take in account the density variable.
Not mandatory, but if I could ppick the number of clusters, it is a plus.
So far, I tried to do a bagging hierarchical clustering to solve the resilient issue (worse than the non-bagging one) and to play with the normalisation of the variables. But My ideas come to an end.
I code with R, but nice solutions in python welcome.