前端通过shpwrite.js导出shp数据
shpwrite是个开源的js包,依靠node来导出shp文件。但是原生js有些问题,无法导出多个面的shp文件,需要自行修改源代码。遗留问题:导出的dbf属性表中文乱码,还在解决中。
·
shpwrite是个开源的js包,依靠node来导出shp文件。但是原生js有些问题,无法导出多个面的shp文件,需要自行修改源代码。
源码下载地址:https://github.com/hwbllmnn/shp-write/tree/maintenance
这里我在补充一下,源码中获取面点的集合是三维数组,所以在创建geojson的时候需要这么写:"coordinates": [[[[],[],[]....]]] (其实这种就属于多面的写法,但是源码中并不支持MultiPolygon)
导出代码
var shpwrite = require('shp-write');
// (optional) set names for feature types and zipped folder
var options = {
folder: 'myshapes',
types: {
point: 'mypoints',
polygon: 'mypolygons',
line: 'mylines'
}
}
// a GeoJSON bridge for features
shpwrite.download({
type: 'FeatureCollection',
features: [
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0, 0]
},
properties: {
name: 'Foo'
}
},
{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0, 10]
},
properties: {
name: 'Bar'
}
}
]
}, options);
遗留问题:导出的dbf属性表中文乱码,还在解决中。
更多推荐
已为社区贡献2条内容
所有评论(0)