knn_weights
Compute a k-nearest neighbors spatial weights matrix from point data. Provide the point file path and number of neighbors to generate a W object for spatial autocorrelation or econometric analysis.
Instructions
Create a k-nearest neighbors spatial weights (W) object from point data.
data_path: path to point shapefile or GeoPackage
k: number of nearest neighbors
id_field: optional attribute name to use as observation IDs
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data_path | Yes | ||
| k | Yes | ||
| id_field | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||