常见gis几何格式(wkt、geojson、arcgis json)的转换方法

1.相关链接

https://github.com/terraformer-js/terraformer

2.arcgis geometry json与geojson互转

Convert ArcGIS JSON geometries to GeoJSON geometries and vice versa.

复制代码
npm install @terraformer/arcgis

(1)arcgis geometry json转换成geojson格式

复制代码
import { arcgisToGeoJSON } from "@terraformer/arcgis"

arcgisToGeoJSON({
  "x":-122.6764,
  "y":45.5165,
  "spatialReference": {
    "wkid": 4326
  }
});

>> { "type": "Point", "coordinates": [ -122.6764, 45.5165 ] }

(2)geojson转换成arcgis geometry json

复制代码
import { geojsonToArcGIS } from "@terraformer/arcgis"

geojsonToArcGIS({
  "type": "Point",
  "coordinates": [45.5165, -122.6764]
})

>> { "x":-122.6764, "y":45.5165, "spatialReference": { "wkid": 4326 } }

3.wkt与geojson格式互转

Tools to convert WKT geometries to GeoJSON geometries and vice versa.

(1)wkt转成geojson

复制代码
import { wktToGeoJSON } from "@terraformer/wkt"

wktToGeoJSON("POINT (-122.6764 45.5165)");

>> { "type": "Point", "coordinates": [ -122.6764, 45.5165 ] }

(2)geojson转成wkt

复制代码
import { geojsonToWKT } from "@terraformer/wkt"

const geojsonPoint = {
  "type": "Point",
  "coordinates": [-122.6764, 45.5165]
}

geojsonToWKT(geojsonPoint)

>> "POINT (-122.6764 45.5165)"
相关推荐
孙 悟 空3 天前
ArcGIS Maps SDK for JavaScript:使用图层过滤器只显示FeatureLayer的部分要素
javascript·arcgis
如影随从3 天前
11 - ArcGIS For JavaScript -- 高程分析
前端·javascript·arcgis·高程分析
菥菥爱嘻嘻3 天前
React---day8
前端·react.js·arcgis
jr4283 天前
【ArcGIS应用】ArcGIS‌应用如何进行影像分类?
arcgis
生态笔记4 天前
ArcGIS计算多个栅格数据的平均栅格
经验分享·arcgis
GIS思维5 天前
ArcGIS Pro字段计算器与计算几何不可用,显示灰色
arcgis·arcgis pro
流年viv6 天前
ArcGIS Pro 创建渔网格网过大,只有几个格网的解决方案
arcgis
新中地GIS开发老师6 天前
新中地三维GIS开发智慧城市效果和应用场景
javascript·arcgis·智慧城市·gis开发·webgis·地理信息科学
小小弯_Shelby8 天前
arcgis js 4.x 的geometryEngine计算距离、面积、缓冲区等报错、失败
arcgis
come112349 天前
全面解析:npm 命令、package.json 结构与 Vite 详解
arcgis·npm·json