build_transform_and_save_weights
Generate and save spatial weights for GIS analysis by reading a shapefile, applying methods like queen, rook, or knn, transforming weights if needed, and exporting them in GAL or GWT format.
Instructions
Pipeline: Read shapefile, build spatial weights, optionally transform, and save to file.
Parameters:
- data_path: Path to point shapefile or GeoPackage
- method: 'queen', 'rook', 'distance_band', 'knn'
- id_field: Optional field name for IDs
- threshold: Distance threshold (required if method='distance_band')
- k: Number of neighbors (required if method='knn')
- binary: True for binary weights, False for inverse distance (DistanceBand only)
- transform_type: 'r', 'v', 'b', 'o', or 'd' (optional)
- output_path: File path to save weights
- format: 'gal' or 'gwt'
- overwrite: Allow overwriting if file exists
Input Schema
Name | Required | Description | Default |
---|---|---|---|
binary | No | ||
data_path | Yes | ||
format | No | gal | |
id_field | No | ||
k | No | ||
method | No | queen | |
output_path | No | weights.gal | |
overwrite | No | ||
threshold | No | ||
transform_type | No |
Input Schema (JSON Schema)
{
"properties": {
"binary": {
"default": true,
"title": "Binary",
"type": "boolean"
},
"data_path": {
"title": "Data Path",
"type": "string"
},
"format": {
"default": "gal",
"title": "Format",
"type": "string"
},
"id_field": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Id Field"
},
"k": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"title": "K"
},
"method": {
"default": "queen",
"title": "Method",
"type": "string"
},
"output_path": {
"default": "weights.gal",
"title": "Output Path",
"type": "string"
},
"overwrite": {
"default": false,
"title": "Overwrite",
"type": "boolean"
},
"threshold": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"title": "Threshold"
},
"transform_type": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"title": "Transform Type"
}
},
"required": [
"data_path"
],
"title": "build_transform_and_save_weightsArguments",
"type": "object"
}