Hi Oleksandr, Yes, if by "width" and "height" one means the geometric width in the direction of the axes of the coordinate system.
If you want to measure the _mean_ width of the object, you need to calculate a convex hull and inscribe it in a circle. https://en.wikipedia.org/wiki/Mean_width Cheers, Kristian On Tue, Feb 17, Oleksandr Huziy wrote: > Hi Jake: > > will your method work when the polygon sides are not parallel to the axes? > > Cheers > > 2015-02-17 9:22 GMT-05:00 Jake Wasserman <jwasser...@gmail.com>: > > > Hi Yuta, > > You can use the `bounds` property on Shapely geometry objects to help ( > > http://toblerity.org/shapely/manual.html#object.bounds). > > This should work: > > > > poly = shapely.geometry.Polygon([(0,0), (1,0), (1,3), (0, 3)]) > > minx, miny, maxx, maxy = poly.bounds > > > > width = maxx - minx > > height = maxy - miny > > diagonal = math.hypot(width, height) > > > > You can always wrap that into a function if you find yourself reusing it a > > lot. > > > > -Jake > > > > > > > > On Tue, Feb 17, 2015 at 9:04 AM, Yuta Sato <yutaxs...@gmail.com> wrote: > > > >> Dear Shapely Developers and Users: > >> > >> I am a regular user of shapely. > >> > >> I want to see more smarter shapely. > >> > >> Meanwhile, could you add an ability to calculate length of height, width, > >> and diagonal of a rectangular polygon? > >> > >> It would be great help if someone could write a function in Python using > >> existing shapely for that. > >> > >> Thanks. > >> > >> Yuta _______________________________________________ Community mailing list Community@lists.gispython.org http://lists.gispython.org/mailman/listinfo/community