pythongeometrygeosjtsshapely

Is there an envelope class in shapely?


I found the envelope class in Java's JTS library very handy. An envelope holds the minimal and maximal coordinates of a geometry and is also called bounding box sometimes.

I wanted to get the common envelope of a number of shapely points. In JTS you could call expandToInclude to enlarge the envelope point by point.

As JTS was serving as a blueprint to GEOS / shapely, I was expecting something similar in shapely, but could not find it (I am new to the library though). I know it is no rocket science to do it yourself, but I doubt there is no more elegant way to do this. Do you have any idea?


Solution

  • No, there's no envelope class in Shapely, which relies on (minx, miny, maxx, maxy) tuples. If you wanted to program in the same JTS style, it would be trivial to write an envelope class wrapping such a tuple.

    Another option:

    from shapely.geometry import MultiPoint
    print MultiPoint(points).bounds