twistedqbit
twistedqbit

Reputation: 127

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.

Upvotes: 11

Views: 11440

Answers (1)

Fejs
Fejs

Reputation: 2888

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

print Polygon([(0,0), (4,0), (2,4)]).length

Upvotes: 26

Related Questions