Extent, envelope, xMin/Max, and yMin/Max for GeoJSON
npm install geojson-boundsDesigned to follow PostGIS's conventions for these operations as much as possible.
npm install geojson-bounds
``Example usage
``
var st = require('geojson-bounds');var shape = { "type": "Polygon",
"coordinates": [
[ [100.1, 0.1], [101.0, 0.1], [101.0, 1.0], [100.1, 1.0], [100.1, 0.1] ],
[ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ]
]
}
st.extent(shape)
// => [ 100.1, 0.1, 101, 1 ]
st.envelope(shape)
// => {"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[100.1,0.1],[100.1,1],[101,1],[101,0.1],[100.1,0.1]]]}}
st.xMin(shape)
// => 100.1
st.xMax(shape)
// => 101
st.yMin(shape)
// => 0.1
st.yMax(shape)
// => 1
``
API
$3
Returns an array of coordinates in the order [West, South, East, North] that represents the
extent of the provided feature or geometry.
$3
Returns a GeoJSON Feature` polygon that repesents the bounding box of the provided feature or geometry.