Skip to main content
Glama

Turf-MCP

by es3154

transformation_voronoi

Generate Voronoi polygons from point data to create spatial regions where each area contains all locations closest to a specific point.

Instructions

生成 Voronoi 多边形。

该函数使用 Turf.js 库的 voronoi 方法,从点集生成 Voronoi 多边形。

Args: points: 点集 GeoJSON FeatureCollection - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 必须符合 GeoJSON FeatureCollection 规范,包含 Point 特征 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}, ...]}'

options: 可选参数配置 - 类型: str (JSON 字符串) 或 None - 可选字段: - bbox: 裁剪矩形边界框 (默认: [-180,-85,180,-85]) - 示例: '{"bbox": [-70, 40, -60, 60]}'

Returns: str: JSON 字符串格式的 Voronoi 多边形集合 GeoJSON FeatureCollection - 类型: GeoJSON FeatureCollection with Polygon features - 格式: {"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [...]}}]} - 示例: '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[-75.35, 39.98], [-75.34, 39.99], ...]]}}, ...]}'

Raises: Exception: 当 JavaScript 执行失败、超时或输入数据格式错误时抛出异常

Example: >>> import asyncio >>> points = '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [-75.343, 39.984]}}]}' >>> options = '{"bbox": [-70, 40, -60, 60]}' >>> result = asyncio.run(voronoi(points, options)) >>> print(result) '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[-75.35, 39.98], [-75.34, 39.99], ...]]}}, ...]}'

Notes: - 输入参数 points 和 options 必须是有效的 JSON 字符串 - 坐标顺序为 [经度, 纬度] (WGS84 坐标系) - 算法来自 d3-voronoi 包 - 每个输入点对应一个输出多边形 - 依赖于 Turf.js 库和 Node.js 环境

Input Schema

NameRequiredDescriptionDefault
optionsNo
pointsYes

Input Schema (JSON Schema)

{ "properties": { "options": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null }, "points": { "type": "string" } }, "required": [ "points" ], "type": "object" }

Other Tools from Turf-MCP

Related Tools

    MCP directory API

    We provide all the information about MCP servers via our MCP API.

    curl -X GET 'https://glama.ai/api/mcp/v1/servers/es3154/turf-mcp'

    If you have feedback or need assistance with the MCP directory API, please join our Discord server