Spatial clustering with attribute

I need to do some sort of spatial clustering where each spatial coordinate has a value attribute. So, for example, each point has a salary attached to it.

So each cluster would have a total salary if I summed each point's salary. But I want to have each cluster to be between a certain total salary. For example, New York can spatially be one cluster but based on the total salary it should be three.

I need to do spatial clustering with a constraint on that total salary so it falls between two values.

Right now all I have is some Python for hierarchical spatial clustering but I don't know how to take into account the attribute!

• Unfortunately, it doesn't make sense. Could you edit your question? I think some data is missing, where is supposed to be coming from this 80-100 range? – Albert Jan 27 '17 at 7:43
• The range that the sum can fall into would be inputted I wouldn't need the clustering to tell me what the range should be. – Tylerr Jan 27 '17 at 13:00
• I have this problem too. I can cluster the points, but can't tell which points belong to which cluster, so I can't summarize the value attribute. @Tylerr, did you ever figure this out? – Shawn Dec 13 '18 at 18:14
• @Shawn if you just need the labels and are using sklearn then you can call the "label_" attribute after you fit your data then join/merge your values to the labels (assuming you set the index or add a key to join on) and then use a groupby to get the cluster sums/averages or whatever you need. If you need to do constrained clustering then: I ended up creating a distance matrix for each point then iteratively combined each point with the nearest point/cluster if and only if the sum of the cluster values would stay below a certain threshold. There were a few other rules I'll try to remember – Tylerr Dec 15 '18 at 23:32
• @Tylerr Thanks. I'm completely new to this area of GIS, and didn't know about scikit-learn. I'll look into that and see what makes the most sense. – Shawn Dec 17 '18 at 13:44