Apr 28, 2016 · import random import numpy as np import pandas as pd import scipy.spatial from haversine import haversine def distance(p1,p2): return haversine(p1[1:],p2[1:]) def cluster_centroids(data, clusters, k): results=[] for i in range(k): results.append( np.average(data[clusters == i],weights=np.squeeze(np.asarray(data[clusters == i][:,0:1])),axis=0)) return results def kmeans(data, k=None, centroids=None, steps=20): # Forgy initialization method: choose k data points randomly. centroids = data[np ...

Amendment project ideasNov 04, 2013 · Based on the latitude and longitude the locations can be clustered and the sizes constrained. In this example I use exactly equal sized clusters (except when n is not divisible by K), . However, the option exists where one could pre-allocated the cluster sizes so they are fixed in advance but are different from cluster to cluster and then ...

Moving along a circle of latitude in order to find the minimum and maximum longitude does not work at all as you can see in figure 1: The points on the query circle having the minimum/maximum longitude, T 1 and T 2, are not on the same circle of latitude as M but closer to the pole.