7

I'm looking for a library (or at least a code snippet) to calculate the minimum bounding box "by width" in JavaScript or Python. Below is an illustration from the ArcGIS documentation of that functionality. Ideally the function would give me also the angle, width and height of the bounding box. Any pointers?

enter image description here

Image courtesy of the ArcGIS documentation

7
  • OpenCV has a module of that sort docs.opencv.org/modules/imgproc/doc/…
    – mlai
    Dec 13 '14 at 3:34
  • Thanks for the OpenCV pointer but I believe this function does a "Rectangle by Area" and not a "by width" approach. Dec 13 '14 at 11:45
  • 1
    Is this what you tried to achieve in JS/Python? gis.stackexchange.com/q/260488/122597 Jan 16 '19 at 15:41
  • Check out turfjs.org bbox and envelope modules, maybe they fit your needs.
    – Nick
    Mar 22 '19 at 1:34
  • QGIS has a "Minimum bounding geometry" tool that do exactly that (and a few of the other possibilities) you may have a look at the algorithm it use (it seem to be using python)
    – J.R
    May 10 '20 at 15:24