Reputation: 2096
I am using library("dbscan")
to cluster geographical data with latitude and longitude. I would like to know which coordinates [latitude, longitude] are belonging to which cluster in R. Is there any way to retrieve the original data points under each cluster?
Example:
latitude = c(60.95886,63.04287,60.79435,61.79435, 64.79435, 61.95886,65.04287,66.79435,63.79435, 65.79435,66.79435, 68.79435,69.79435 )
longitude = c(27.79045,22.87444,24.51007, 23.49429, 23.49429, 28.79045,23.87444,26.51007, 25.49429, 26.49429,26.49429, 29.49429,30.49429)
testData = data.frame(latitude,longitude)
clust <- dbscan(testData, eps = 1.5, minPts = 3)
clust
DBSCAN clustering for 13 objects.
Parameters: eps = 1.5, minPts = 3
The clustering contains 2 cluster(s) and 7 noise points.
0 1 2
7 3 3
Here I want to know the data points from testData belonging to cluster 1 and 2
Upvotes: 1
Views: 924
Reputation: 8377
add the output of dbscan to your initial data.frame.
testData$cluster = clust$cluster
Upvotes: 1