Here are some basic geometric operations we can perform on our polygon. We create the area, centroid, boundary, convex hull, buffer, and check if a polygon contains a certain point:
# 1 create areaIn: print("The area of our polygon is %d" % polygon.Area())Out: The area of our polygon is 16# 2 calculate centroid of polygonIn: cen = polygon.Centroid()print(cen)Out: POINT (3 3)# 3 Get the boundaryIn: b = polygon.GetBoundary()print(b)Out: LINESTRING (1 1,5 1,5 5,1 5,1 1)# 4 convex hull does the same in this case as boundary, as our polygon is a square:In: ch = polygon.ConvexHull() print(ch)Out: POLYGON ((1 1,1 5,5 5,5 1,1 1))# 5 buffer. A buffer value of 0 (zero) returns the same values as boundary and convex hull in ...