Skip to content

cluster_points

The full machine-readable contract.

Input schema (JSON Schema)

{
  "type": "object",
  "required": ["geojson"],
  "properties": {
    "geojson": {
      "type": "string",
      "description": "A GeoJSON FeatureCollection of Point features."
    },
    "eps": {
      "type": "number",
      "default": 1000,
      "minimum": 0,
      "description": "Maximum metres between two points to be in the same neighbourhood."
    },
    "minPts": {
      "type": "integer",
      "default": 3,
      "minimum": 1,
      "description": "Minimum points to form a cluster."
    }
  }
}

Output

A GeoJSON FeatureCollection. Each Feature has:

Field Type Description
geometry.type string Always "Polygon".
geometry.coordinates array 32-vertex regular polygon ring centred on the cluster centroid.
properties.cluster_id integer Stable per-response index, 0-based.
properties.point_count integer Number of input points in this cluster.
properties.radius_meters number Distance from centroid to the furthest member point.
properties.kartoza_credit string Provenance: "Processed by Kartoza.com tools".

Algorithm

  1. Parse input GeoJSON into orb.Point slice.
  2. Insert all points into a quadtree.Quadtree keyed by lon/lat.
  3. In parallel (one goroutine per numWorkers, default 8) compute each point's eps-neighbourhood using geo.Distance for true geodesic filtering.
  4. Run DBSCAN single-threaded, expanding clusters by reusing the pre-computed neighbours.
  5. For each cluster, compute centroid + max-radius and emit a 32-vertex polygon approximation of the bounding circle.

Complexity: O(N log N) average case, dominated by the parallel neighbour pre-pass.

Edge cases

Input Behaviour
Empty FeatureCollection "No points found in collection" text result.
Mix of Point and Polygon features Polygons silently ignored.
All points within eps of one another Single cluster.
No two points within eps Zero clusters returned.
minPts > len(points) Zero clusters returned.
eps == 0 Zero clusters returned.
Invalid JSON Error: "failed to parse GeoJSON: …"

Example call

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "cluster_points",
    "arguments": {
      "geojson": "{\"type\":\"FeatureCollection\",\"features\":[...]}",
      "eps": 2500,
      "minPts": 4
    }
  }
}