Given a polygon which is constructed like this:
from shapely.geometry import Polygon
print Polygon([(0,0), (4,0), (2,4)]).area
this correctly computes the area of the triangle. However, if i replace the area attribute with 'perimeter' I get the following message: 'Polygon' object has no attribute 'perimeter' which seems absurd. Surely, shapely must be able to find the perimeter of a polygon as easily as the area? I've googled this topic for some time (e.g. 'python shapely perimeter' and 'python polygon perimeter') but no relevant results appear.
So please help me find a command inside shapely that allows me to compute the perimeter of my polygon.
According to docs, you should use .length
attribute like this:
print Polygon([(0,0), (4,0), (2,4)]).length
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With