1. Go to this page and download the library: Download waxwink/clustering library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$output = Clustering::getClusters($points, 0.1);
//The second parameter is the length of the square spaces by which the points are going to be clusterd.
//output :
/*
array (size=3)
0 =>
array (size=3)
'lat' => float 35.821006
'lng' => float 51.427388
'total' => int 1
1 =>
array (size=3)
'lat' => float 35.697391
'lng' => float 51.3989685
'total' => int 2
2 =>
array (size=3)
'lat' => float 35.743621
'lng' => float 51.530846
'total' => int 1
*/
$output = Clustering::getClusters($points, 2, Clustering::K_MEANS_ALGORITHM, 5);
//the second parameter is the number of clusters
//the third parameter is the algorithm
//the forth parameter is the number of iterations used in the K-means algorithm which is 5 by default
//output:
/*
array (size=2)
0 =>
array (size=3)
'lat' => float 35.821006
'lng' => float 51.427388
'total' => int 1
1 =>
array (size=3)
'lat' => float 35.712801
'lng' => float 51.442927666667
'total' => int 3
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.