@mapbox/geojson-coords

return all coordinates from a geojson object

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@mapbox/geojson-coords
2920.0.22 years ago6 years agoMinified + gzip package size for @mapbox/geojson-coords in KB

Readme

geojson-coords
Extract coordinates from GeoJSON.

install

npm install --save @mapbox/geojson-coords

api

coords(geojson)

Given any valid GeoJSON object, return a single array of coordinates that it contains. Handles any root object, collapses multidimensional coordinate arrays and expands point coordinate arrays.

example

```js var geojsonCoords = require('@mapbox/geojson-coords');
geojsonCoords({
"type": "GeometryCollection",
"geometries": [
    {
        "type": "Point",
        "coordinates": [100.0, 0.0]
    },
    {
        "type": "LineString",
        "coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
    }
]
}); // returns 100, 0, 101, 0, 102, 1;