geojson-multiply
Multiply single type geojsons into a multi type geojson
Install
npm install geojson-multiply
How to Use
geojson-multiply
provides following function:
multiply(geojsons[, options])
Where,
-
geojson
- a geojson feauture, an array of geojson features, or a geojson feature collection -
options
- some additional options for property aggregation:-
properties
- the default properties of result geojson -
onEachFeature
- a function to aggregate properties. It has four parameters:-
properties
- the result geojson's properties -
featureProp
- input feature geojson's properties -
index
- input feature geojson's index in the array -
geojsons
- geojson array.
Similar to reduce().
-
-
If successes, the function will return a feature geojson with Multi geometry type.
If fails, the function will return a null
.
Example
var multiply = ;var geojsonA =type: 'Feature'geometry: type: 'Point' coordinates: 12 43properties: count: 5;var geojsonB =type: 'Feature'geometry: type: 'Point' coordinates: 13 34properties: count: 5;var {propertiescount += featurePropcount;return properties;};var result =;/**The reuslt geojson should be{type: 'Feature'geometry: {type: 'MultiPoint',coordinates: [[12, 43], [14, 34]]},properties: {count: 10}}*/