#创建 SF 对象
from osgeo import ogr
#SF 对象的 WKT 表示格式
pnt_wkt = "POINT(1 1)"
lin_wkt = "LINESTRING(0 0,15 15) "
pol_wkt = "POLYGON((1 1,1 10,10 10,10 1,1 1),( 2 2,2 8,8 8,8 2,2 2)) "
#创建 SF 对象
pnt = ogr.CreateGeometryFromWkt(pnt_wkt)
lin = ogr.CreateGeometryFromWkt(lin_wkt)
pol = ogr.CreateGeometryFromWkt(pol_wkt)
#Geometry 的相关信息
dir(pol)
pol.GetArea()
pol.GetGeometryType()
pol.GetGeometryName()
pol.GetEnvelope()
pol.GetGeometryCount()
ring1 = pol.GetGeometryRef(0)
ring1.GetPointCount()
ring1.GetPoints()
ring2 = pol.GetGeometryRef(1)
ring2.GetPointCount()
ring2.GetPoints()
pol.Centroid()
pol.Buffer(10)
转载于:https://www.cnblogs.com/vividautumn/p/11557354.html