SPATIAL
cKDTree
cKDTree(data, leafsize=16, compact_nodes=True, copy_data=False,.
Example of usage
Python API reference included; executable data demonstration pending review.
Usage / limitations
+Use when: Analyse spatial geometry.
−Limitations: Check input requirements, mathematical assumptions and version-specific behaviour before using.
Mathematical formula
See method documentation: implementation and assumptions vary.
Sample dataShow
{
"variable": "site_locations",
"domain": "Urban logistics and distribution-site planning",
"feature_names": [
"east_km",
"north_km"
],
"records": [
{
"site": "Depot A",
"east_km": 0,
"north_km": 0
},
{
"site": "Depot B",
"east_km": 2,
"north_km": 0
},
{
"site": "Depot C",
"east_km": 0,
"north_km": 2
},
{
"site": "Depot D",
"east_km": 2,
"north_km": 2
},
{
"site": "Depot E",
"east_km": 1,
"north_km": 1
},
{
"site": "Depot F",
"east_km": 3,
"north_km": 1
}
]
}
Code example (Python)
site_locations = {'variable': 'site_locations', 'domain': 'Urban logistics and distribution-site planning', 'feature_names': ['east_km', 'north_km'], 'records': [{'site': 'Depot A', 'east_km': 0, 'north_km': 0}, {'site': 'Depot B', 'east_km': 2, 'north_km': 0}, {'site': 'Depot C', 'east_km': 0, 'north_km': 2}, {'site': 'Depot D', 'east_km': 2, 'north_km': 2}, {'site': 'Depot E', 'east_km': 1, 'north_km': 1}, {'site': 'Depot F', 'east_km': 3, 'north_km': 1}]}
# DataLens.ai example — cKDTree
# Domain: urban logistics and distribution-site planning.
# Sample input is provided by the Copy input + code + test button.
import numpy as np
from scipy import spatial
sites = np.array([[r["east_km"], r["north_km"]] for r in site_locations["records"]], dtype=float)
# Build a fast spatial index and find the closest depot to a delivery point.
tree = spatial.cKDTree(sites)
distance, index = tree.query([0.2, 0.1])
assert index == 0 and np.isclose(distance, np.hypot(0.2, 0.1))
print("Expected output verified")
# DataLens.ai example — cKDTree
# Domain: urban logistics and distribution-site planning.
# Sample input is provided by the Copy input + code + test button.
import numpy as np
from scipy import spatial
sites = np.array([[r["east_km"], r["north_km"]] for r in site_locations["records"]], dtype=float)
# Build a fast spatial index and find the closest depot to a delivery point.
tree = spatial.cKDTree(sites)
distance, index = tree.query([0.2, 0.1])
assert index == 0 and np.isclose(distance, np.hypot(0.2, 0.1))
print("Expected output verified")