This Javascript/Typescript library provides 2 methods for calculating the Minimum Bounding Rectangle by area and by width for a given GeoJSON feature or feature collection.
This problem it is solving has many names: Minimum Bounding Rectangle, Minimum Bounding Box, Smallest Surrounding Rectangle, Minimum Area Rectangle...
This is an example of the output of this library. The input GeoJSON is the yellow polygon (outline of the Republic of Ireland).
The blue rectangle was generated by smallestSurroundingRectangleByWidth
while the red rectangle is the output of smallestSurroundingRectangleByArea
The function of the library is unchanged, but all dependencies were updated to turf 7. The library is now also ES-Modules only.
In case you need CommonJS or compatability with older version of TurfJS, use version 1.0.1
npm install geojson-minimum-bounding-rectangle
import {
smallestSurroundingRectangleByWidth,
smallestSurroundingRectangleByArea,
} from 'geojson-minimum-bounding-rectangle';
const boundingRect = smallestSurroundingRectangleByWidth(myGeoJsonInput);
- https://en.wikipedia.org/wiki/Minimum_bounding_box_algorithms
- https://gis.stackexchange.com/questions/22895/finding-minimum-area-rectangle-for-given-points
See LICENSE for more details.