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
- shapefile
python:str
shapefile name with shp suffix.
- radius
python:float
If supplied arc_distances will be calculated based on the given radius. p will be ignored.
- p
python:float
Minkowski p-norm distance metric parameter: 1<=p<=infinity 2: Euclidean distance 1: Manhattan distance
- shapefile
- Returns
- d
python:float
Maximum nearest neighbor distance between the n observations.
- d
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