Clear Filters
Clear Filters

How do I cluster spatial data with only one attribute?

3 views (last 30 days)
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:
  1. How do I ensure that the spatial information is included in the optimization problem?
  2. 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
Data.longitude(end,1)= -1.856;
Data.latitude(end,1)= 38.994;
Data.Attribute1(end)= 2;
% Define colors
Colormapclust=Colormap([1 end],:);
% 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;
plot(ZIPcode(:,1),ZIPcode(:,2));hold on;
% Figure of the clustered data
[idx_clust,Cluster]=kmeans([Data.longitude Data.latitude Data.Attribute1],ncluster);
for i=1:ncluster
scatter(Data.longitude(Data.cluster==i),Data.latitude(Data.cluster==i),10,Colormapclust(i,:),'filled'), hold on;
Thanks a lot.

Answers (0)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!