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