How do I cluster spatial data with only one attribute?
5 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
Data.longitude(end,1)= -1.856;
Data.latitude(end,1)= 38.994;
Data.Attribute1(end)= 2;
% Define colors
Colormap=jet(7);
Colormapclust=Colormap([1 end],:);
% Figure of the original data
figure;
for i=[2 6]
scatter(Data.longitude(Data.Attribute1==i),Data.latitude(Data.Attribute1==i),10,Colormap(i,:),'filled'), hold on;
end
plot(ZIPcode(:,1),ZIPcode(:,2));hold on;
% Figure of the clustered data
figure;
ncluster=2;
[idx_clust,Cluster]=kmeans([Data.longitude Data.latitude Data.Attribute1],ncluster);
Data.cluster=idx_clust;
for i=1:ncluster
scatter(Data.longitude(Data.cluster==i),Data.latitude(Data.cluster==i),10,Colormapclust(i,:),'filled'), hold on;
end
Thanks a lot.
0 Comments
Answers (0)
See Also
Categories
Find more on Cluster Analysis and Anomaly Detection 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!