Skip to main content
Glama

Turf-MCP

by es3154

feature_conversion_line_to_polygon

Convert line geometries to polygon geometries by automatically closing line segments to create complete polygon boundaries 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]]}'

options: 可选参数配置 - 类型: str (JSON 字符串) 或 None - 可选字段: - properties: 传递给多边形的属性对象 - autoComplete: 是否自动完成线段闭合 - orderCoords: 是否重新排序坐标 - mutate: 是否修改原始线特征 - 示例: '{"properties": {"name": "converted polygon"}}'

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

NameRequiredDescriptionDefault
lineYes
optionsNo

Input Schema (JSON Schema)

{ "properties": { "line": { "type": "string" }, "options": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null } }, "required": [ "line" ], "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