# pysal.lib.cg.KDTree¶

pysal.lib.cg.KDTree(data, leafsize=10, distance_metric='Euclidean', radius=6371.0)[source]

kd-tree built on top of kd-tree functionality in scipy. If using scipy 0.12 or greater uses the scipy.spatial.cKDTree, otherwise uses scipy.spatial.KDTree. Offers both Arc distance and Euclidean distance. Note that Arc distance is only appropriate when points in latitude and longitude, and the radius set to meaningful value (see docs below).

Parameters: data : array The data points to be indexed. This array is not copied, and so modifying this data will result in bogus results. Typically nx2. leafsize : int The number of points at which the algorithm switches over to brute-force. Has to be positive. Optional, default is 10. distance_metric : string Options: “Euclidean” (default) and “Arc”. radius : float Radius of the sphere on which to compute distances. Assumes data in latitude and longitude. Ignored if distance_metric=”Euclidean”. Typical values: pysal.cg.RADIUS_EARTH_KM (default) pysal.cg.RADIUS_EARTH_MILES