普通的geoJSON文件合并,只需geojson-merge插件就够了,https://www.npmjs.com/package/@mapbox/geojson-merge
合并文件,官网的案例
var geojsonMerge = require('@mapbox/geojson-merge');
var mergedStream = geojsonMerge.mergeFeatureCollectionStream(['features.geojson','others.geojson'])
mergedStream.pipe(process.stdout);
在浏览器端,需要导入文件,fileReader读取文件,获取json,再合并
var geojsonMerge = require('@mapbox/geojson-merge')
let features = []
// Todo push jgeoJSON
let jsonObject = geojsonMerge.merge(features)
GeoJSON一feature properties过滤
https://www.npmjs.com/package/turf-filter
turf.filter(features, key, value)
var features = turf.featurecollection([
turf.point([-72.581777, 44.260875], {species: 'oak'}),
turf.point([-72.570018, 44.260691], {species: 'birch'}),
turf.point([-72.576284, 44.257925], {species: 'oak'}),
turf.point([-72.56916, 44.254605], {species: 'redwood'}),
turf.point([-72.581691, 44.24858], {species: 'maple'}),
turf.point([-72.583837, 44.255773], {species: 'oak'})
]);
var key = 'species';
var value = 'oak';
var filtered = turf.filter(features, key, value);
这个过滤比较简单,https://www.npmjs.com/package/feature-filter-geojson
可以增加过滤规则,具体还是看官方文档。在浏览器端,其实用第一个就好
var ff = require('feature-filter');
var filter = [
"all",
["==", "class", "street_limited"],
["<=", "admin_level", 3],
["!=", "$type", "Polygon"]
]
var testFilter = ff(filter);
let feature = GeoJSONObject
testFilter(feature);
https://www.npmjs.com/package/geojson-filter,这个也是一样的,但是推荐用第一个
GeoJSON 里面的点线面合并为Multi(point/linestring/polygon)
Dissolve contiguous GeoJSON (Multi)LineStrings and (Multi)Polygons into single units.
说实话,这个实际项目,我目前还没有用到。
merge-simple-polygons:https://www.npmjs.com/package/merge-simple-polygons
Merge two (adjacent) simple polygons into another simple polygon.
Takes two arrays of vertex IDs, each spanning a planar polygon and returns:
const mergePolygons = require('merge-simple-polygons')
const polygonA = ['a', 'b', 'c', 'd', 'e']
const polygonB = ['e', 'a', 'g', 'h', 'i', 'd']
const polygonC = mergePolygons(polygonA, polygonB)
console.log(polygonC) // ['a', 'b', 'c', 'd', 'i', 'h', 'g']
const polygonD = ['a', 'b', 'c']
const polygonE = ['d', 'e', 'f']
console.log(mergePolygons(polygonD, polygonE)) // false
const polygonF = ['a', 'b', 'c', 'd', 'e']
const polygonG = ['a', 'b', 'f', 'e', 'd', 'g']
console.log(mergePolygons(polygonF, polygonG)) // null
这个,turfjs http://turfjs.org/docs/#booleanContains
Turn your geo data into GeoJSON.
转载本站文章《GIS常用npm包:GeoJSON文件合并与元素过滤\属性过滤\图形合并》, 请注明出处:https://www.zhoulujun.cn/html/GIS/WebGIS/8201.html
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。