Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polygon perimeter

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.

like image 334
Emil Haugen Avatar asked Nov 04 '16 15:11

Emil Haugen


1 Answers

According to docs, you should use .length attribute like this:

print Polygon([(0,0), (4,0), (2,4)]).length
like image 91
Fejs Avatar answered Sep 28 '22 19:09

Fejs