A simple function that finds the central point of a GeoJSON polygon.
Install it with npm install geojson-polygon-center
.
> var polygonCenter = > var geojsonFeatureCollection = ... "type": "FeatureCollection"... "features": ... ... "type": "Feature"... "properties": {}... "geometry": ...... "type": "Point"...... "coordinates": ...... -7734374999999999...... 4607323062540838...... ...... ... ... ... "type": "Feature"... "properties": {}... "geometry": ...... "type": "Polygon"...... "coordinates": ...... ...... ...... -7734026312828064...... 4607364371067343...... ...... ...... -773364007472992...... 460733962320346...... ...... ...... -773359715938568...... 4607358230630263...... ...... ...... -7733838558197021...... 46073781405074676...... ...... ...... -7734026312828064...... 4607364371067343...... ...... ...... ...... ... ... ... > var point = geojsonFeatureCollectionfeatures0> pointgeometrytype'Point'> var center = > center type: 'Point' coordinates: 0 0 >> var polygon = geojsonFeatureCollectionfeatures1> polygongeometrytype'Polygon'> var center = > center type: 'Point' coordinates: -7733811736106873 4607358881855464