命令行记录-创建SF对象

#创建 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)

posted @ 2019-09-20 15:09  vivid_autumn  阅读(233)  评论(0编辑  收藏  举报