import os
from osgeo import ogr, gdal
shp_path = './1.shp'
ds = ogr.Open(shp_path,0)
layer = ds.GetLayer()
layer.SetAttributeFilter("majority = 1 or majority = 2")
driver = ogr.GetDriverByName('ESRI Shapefile')
out_ds = driver.CreateDataSource('./shp/t.shp')
out_layer = out_ds.CopyLayer(layer, 't')
del layer, ds, out_layer, out_ds
python gdal实现arcpy的SelectLayerByAttribute_management函数
最新推荐文章于 2024-02-04 11:19:58 发布