shp 格式 与 GeoJSON 格式 互相转换工具类(shpUtil)
npm install
或 cnpm install
运行npm run build
来构建项目。
安装包
npm install shp-geojson -save
引入包
import * as shpUtil from 'shp-geojson'
//或者
//import { toGeoJSON } from 'shp-geojson'
//直接加载url
shpUtil.toGeoJSON('//data.mars3d.cn/file/shp/test.zip').then((geojoson) => {
console.log(geojoson)
})
//如果您以其他方式获得 zip(例如File API),则可以使用 arrayBuffer 调用
shpUtil.toGeoJSON(buffer).then((geojoson) => {
console.log(geojoson)
})