libpysal.weights.min_threshold_dist_from_shapefile

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

Get the maximum nearest neighbor distance between observations in the shapefile.

Parameters:
shapefilestr

shapefile name with shp suffix.

radiusfloat

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

pfloat

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

Returns:
dfloat

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 libpysal
>>> md = libpysal.weights.min_threshold_dist_from_shapefile(
...     libpysal.examples.get_path("columbus.shp")
... )
>>> md
0.6188641580768541
>>> libpysal.weights.min_threshold_dist_from_shapefile(
...     libpysal.examples.get_path("stl_hom.shp"),
...     libpysal.cg.sphere.RADIUS_EARTH_MILES
... )
31.846942936393717