pysal.lib.weights.min_threshold_dist_from_shapefile

pysal.lib.weights.min_threshold_dist_from_shapefile(shapefile, radius=None, p=2)[source]

Kernel weights with adaptive bandwidths.

Parameters:
shapefile : string

shapefile name with shp suffix.

radius : float

If supplied arc_distances will be calculated based on the given radius. p will be ignored.

p : float

Minkowski p-norm distance metric parameter: 1<=p<=infinity 2: Euclidean distance 1: Manhattan distance

Returns:
d : float

Maximum nearest neighbor distance between the n observations.

Notes

Supports polygon or point shapefiles. For polygon shapefiles, distance is based on polygon centroids. Distances are defined using coordinates in shapefile which are assumed to be projected and not geographical coordinates.

Examples

>>> import pysal.lib
>>> md = pysal.lib.weights.user.min_threshold_dist_from_shapefile(pysal.lib.examples.get_path("columbus.shp"))
>>> md
0.6188641580768541
>>> pysal.lib.weights.user.min_threshold_dist_from_shapefile(pysal.lib.examples.get_path("stl_hom.shp"), pysal.lib.cg.sphere.RADIUS_EARTH_MILES)
31.846942936393717