Home

Awesome

geojson-multiply

Multiply single type geojsons into a multi type geojson

Install

npm install geojson-multiply

How to Use

geojson-multiply provides following function:

Where,

If successes, the function will return a feature geojson with Multi geometry type.

If fails, the function will return a null.

Example


var multiply = require('geojson-multiply');

var geojsonA = {
  type: 'Feature',
  geometry: { type: 'Point', coordinates: [12, 43] },
  properties: { count: 5 }
};

var geojsonB = {
  type: 'Feature',
  geometry: { type: 'Point', coordinates: [13, 34] },
  properties: { count: 5 }
};

var onEachFeature = function(properties, featureProp) {
  properties.count += featureProp.count;
  return properties;
};

var result = multiply([geojsonA, geojsonB], {
  properties: { count: 0 },
  onEachFeature: onEachFeature
});

/**
The reuslt geojson should be
{
  type: 'Feature'
  geometry: {
    type: 'MultiPoint',
    coordinates: [[12, 43], [14, 34]]
  },
  properties: {
    count: 10
  }
}
*/