How to calculate the area of Polygon in python
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!