How do I cluster spatial data with only one attribute?
3 views (last 30 days)
Show older comments
I have longitude and latitude data with one attribute, which can take only two values (my real case has more values, but retains the single attribute property).
I would like to create two contiguous areas as homogeneous as possible with respect to the value of the single attribute I mentioned. For this, I had thought about K-means clustering, but I run into several problems.
The first problem is a conceptual one: does it make sense to cluster only along one dimension?
The other problems are technical:
- How do I ensure that the spatial information is included in the optimization problem?
- How do I ensure that the zones are contiguous?
An additional great thing would be to obtain a polygon of the cluster zone.
To provide you with more information, my use case is the following. I have data on buildings inside a ZIP code, and those buildings can either be a house or a business office. I would like to split my ZIP code into a Residential area (mostly houses) and a Commercial area (mostly businesses and offices). I have attached mock data.
The code so far is the following:
% Put a point in the data to make it non-contiguous
% Define colors
% Figure of the original data
for i=[2 6]
scatter(Data.longitude(Data.Attribute1==i),Data.latitude(Data.Attribute1==i),10,Colormap(i,:),'filled'), hold on;
% Figure of the clustered data
[idx_clust,Cluster]=kmeans([Data.longitude Data.latitude Data.Attribute1],ncluster);
scatter(Data.longitude(Data.cluster==i),Data.latitude(Data.cluster==i),10,Colormapclust(i,:),'filled'), hold on;
Thanks a lot.
Find more on Directed Graphs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!