Skip to main content
Glama
es3154
by es3154

transformation_simplify

Simplify GeoJSON geometries to reduce complexity while preserving shape using configurable tolerance and quality settings.

Instructions

简化 GeoJSON 几何。

该函数使用 Turf.js 库的 simplify 方法,简化给定的 GeoJSON 几何图形。

Args: geojson: GeoJSON 对象 - 类型: str (JSON 字符串格式的 GeoJSON) - 格式: 任何有效的 GeoJSON 对象 - 坐标系: WGS84 (经度在前,纬度在后) - 示例: '{"type": "Polygon", "coordinates": [[[-70.603637, -33.399918], [-70.614624, -33.395332], [-70.639343, -33.392466], [-70.659942, -33.394759], [-70.683975, -33.404504], [-70.697021, -33.419406], [-70.701141, -33.434306], [-70.700454, -33.446339], [-70.694274, -33.458369], [-70.682601, -33.465816], [-70.668869, -33.472117], [-70.646209, -33.473835], [-70.624923, -33.472117], [-70.609817, -33.468107], [-70.595397, -33.458369], [-70.587158, -33.442901], [-70.587158, -33.426283], [-70.590591, -33.414248], [-70.594711, -33.406224], [-70.603637, -33.399918]]]}'

options: 可选参数配置 - 类型: str (JSON 字符串) 或 None - 可选字段: - tolerance: 简化容差 (默认: 1) - highQuality: 是否使用高质量简化 (默认: false) - mutate: 是否允许修改输入对象 (默认: false) - 示例: '{"tolerance": 0.01, "highQuality": true}'

Returns: str: JSON 字符串格式的简化后的 GeoJSON 对象 - 类型: 与输入相同的 GeoJSON 类型 - 格式: 与输入相同的格式 - 示例: '{"type": "Polygon", "coordinates": [[[-70.603637, -33.399918], [-70.614624, -33.395332], [-70.639343, -33.392466], ...]]}'

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

Example: >>> import asyncio >>> geojson = '{"type": "Polygon", "coordinates": [[[-70.603637, -33.399918], [-70.614624, -33.395332], [-70.639343, -33.392466], [-70.659942, -33.394759], [-70.683975, -33.404504], [-70.697021, -33.419406], [-70.701141, -33.434306], [-70.700454, -33.446339], [-70.694274, -33.458369], [-70.682601, -33.465816], [-70.668869, -33.472117], [-70.646209, -33.473835], [-70.624923, -33.472117], [-70.609817, -33.468107], [-70.595397, -33.458369], [-70.587158, -33.442901], [-70.587158, -33.426283], [-70.590591, -33.414248], [-70.594711, -33.406224], [-70.603637, -33.399918]]]}' >>> options = '{"tolerance": 0.01, "highQuality": true}' >>> result = asyncio.run(simplify(geojson, options)) >>> print(result) '{"type": "Polygon", "coordinates": [[[-70.603637, -33.399918], [-70.614624, -33.395332], [-70.639343, -33.392466], ...]]}'

Notes: - 输入参数 geojson 和 options 必须是有效的 JSON 字符串 - 坐标顺序为 [经度, 纬度] (WGS84 坐标系) - tolerance 值越小,简化程度越低 - highQuality 为 true 时使用更精确但更慢的算法 - 依赖于 Turf.js 库和 Node.js 环境

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
geojsonYes
optionsNo

Other Tools

Latest Blog Posts

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