Install
openclaw skills install gis-transform-coords支持GeoJSON格式点、线、面数据在WGS84(经纬度)和Web Mercator(EPSG:3857)坐标系间批量转换。
openclaw skills install gis-transform-coords快速转换点、线、面数据的坐标系:WGS84(经纬度)↔ Web Mercator(EPSG:3857)
python3 ~/.openclaw/workspace/skills/gis-coord-transform/scripts/transform_coords.py input.geojson -t mercator -o output.geojson --pretty
python3 ~/.openclaw/workspace/skills/gis-coord-transform/scripts/transform_coords.py input.geojson -t wgs84 -o output.geojson --pretty
| 类型 | 说明 |
|---|---|
| Point | 点 |
| LineString | 线 |
| Polygon | 面 |
| MultiPoint | 多点 |
| MultiLineString | 多线 |
| MultiPolygon | 多面 |
| Feature | GeoJSON 要素 |
| FeatureCollection | 要素集合 |
| 参数 | 说明 |
|---|---|
input | 输入 GeoJSON 文件路径 |
-o, --output | 输出文件路径(默认输出到 stdout) |
-t, --to | 目标坐标系:mercator 或 wgs84 |
--pretty | 美化输出 JSON |
// input.geojson
{
"type": "Point",
"coordinates": [116.4074, 39.9042]
}
python3 scripts/transform_coords.py input.geojson -t mercator
输出(墨卡托坐标):
{
"type": "Point",
"coordinates": [12958396.7, 4865942.3]
}
python3 scripts/transform_coords.py cities.geojson -t mercator -o cities_mercator.geojson --pretty
for file in *.geojson; do
python3 scripts/transform_coords.py "$file" -t mercator -o "${file%.geojson}_mercator.geojson"
done
pip3 install pyproj
| 坐标系 | EPSG 代码 | 用途 |
|---|---|---|
| WGS84 | EPSG:4326 | GPS、经纬度、地理坐标 |
| Web Mercator | EPSG:3857 | Web 地图(Google Maps、OpenStreetMap、Mapbox 等) |
Web Mercator 使用米为单位,而 WGS84 使用度。墨卡托坐标通常在百万级别。
使用 pyproj 库,精度非常高,适合专业 GIS 应用。
当前版本仅支持 WGS84 ↔ Web Mercator。如需其他坐标系,可扩展 pyproj.Transformer。
需要添加其他坐标系转换时,修改脚本中的 Transformer 定义:
# 例如:WGS84 → CGCS2000 (EPSG:4490)
transformer = Transformer.from_crs("EPSG:4326", "EPSG:4490", always_xy=True)
scripts/transform_coords.py - 坐标转换主脚本