- 点线面数据
点:[103.8810, 31.0896]
线:[[103.7767, 30.8424],[104.2546, 30.8150],[104.3068, 30.4552]]
面:[[[103.8810, 31.0896],[104.0129, 30.8891],[103.7520, 30.8809],[103.8810, 31.0896]]]
- wkt数据
点:POINT(103.365926 30.558386)
线:LINESTRING(104.079727 30.540988,104.067608 30.535152)
面:POLYGON ((103.88109322629896 31.089692013481724, 104.01292916379867 30.88919152520053, 103.75200387083044 30.880951779106482, 103.88109322629896 31.089692013481724))
多面:MULTIPOLYGON(((104.4685243069 30.3336904936,104.4670262929 30.33037331,104.4644834911 30.3312774512,104.464433366 30.3313740694,104.4659245068 30.3346309237,104.4685243069 30.3336904936)))
- 点线面数据转为geojson
turf文档
import * as turf from '@turf/turf';
点转为geojson :
let point = turf.point([-75.343, 39.984])
geojson point 格式:
线转为geojson :turf.lineString([[103.7767, 30.8424],[104.2546, 30.8150],[104.3068, 30.4552]])
面转为geojson :turf.polygon([[[103.8810, 31.0896],[104.0129, 30.8891],[103.7520, 30.8809],[103.8810, 31.0896]]])
- geojson与wkt互转
import { stringify, parse } from 'wellknown'; // 坐标转换
stringify:geojson转wkt;
parse:wkt转geojson;