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]}}, ...]}'
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
| Name | Required | Description | Default |
|---|---|---|---|
| options | No | ||
| points | Yes |