Datalens.ai
← All algorithms

SPATIAL

SphericalVoronoi

Voronoi diagrams on the surface of a sphere.

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)

# DataLens.ai example — SphericalVoronoi
# 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)

# Partition a unit sphere into regions around geographic directions.
directions = np.array([[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]],dtype=float)
regions = spatial.SphericalVoronoi(directions, radius=1.0, center=[0,0,0])
regions.sort_vertices_of_regions()
assert len(regions.regions) == 6
assert np.isclose(sum(regions.calculate_areas()), 4*np.pi, rtol=1e-8)

print("Expected output verified")