Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to calculate the area of Polygon in python

Shulou Source: shulou.com Published: 2022-06-02 07:11:24 10月04日 Update

It is believed that many inexperienced people have no idea about how to calculate the polygon area in python. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

Implementation code:

Def polygon_area (polygon): "compute polygon area polygon: list with shape [n, 2], n is the number of polygon points" area = 0Q = polygon [- 1] for p in polygon: area + = p [0] * Q [1]-p [1] * Q [0] Q = p return area / 2.0polygon = np.array ([[0,0], [- 1,1], [0] 2], [1,1]). Astype ("float32") area = polygon_area (polygon) print (area) # 2.0 read the above Have you mastered the method of calculating the area of polygons in python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Polygons area content method more problem helpless for this code reason this skills articles experience industry information information channels channels Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia OPPO Reno Shulou Tech Info Docker Huawei