feature_conversion_polygon_to_line
Convert polygon geometries to line geometries by extracting polygon boundaries. This tool transforms GeoJSON polygons into line or multi-line features for spatial analysis and visualization.
Instructions
将多边形转换为线几何图形。
此功能将多边形或多边形几何图形转换为线或多线几何图形,提取多边形的边界。
Args: polygon: GeoJSON 多边形特征或几何图形 - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 必须符合 GeoJSON Polygon 或 MultiPolygon 规范 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "Polygon", "coordinates": [[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]}'
Returns: str: JSON 字符串格式的 GeoJSON LineString 或 MultiLineString 特征 - 类型: GeoJSON Feature with LineString or MultiLineString geometry - 格式: {"type": "Feature", "geometry": {"type": "LineString", "coordinates": [...]}}
Raises: Exception: 当 JavaScript 执行失败、超时或输入数据格式错误时抛出异常
Example: >>> import asyncio >>> polygon = '{"type": "Polygon", "coordinates": [[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]}' >>> result = asyncio.run(polygon_to_line(polygon)) >>> print(result) '{"type": "Feature", "geometry": {"type": "LineString", "coordinates": [[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]}}'
Notes: - 输入参数 polygon 必须是有效的 JSON 字符串 - 坐标顺序为 [经度, 纬度] (WGS84 坐标系) - 提取多边形的边界作为线几何图形 - 依赖于 Turf.js 库和 Node.js 环境
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| polygon | Yes |