我正在尝试更改shapefile的字段值。但是,它不会更改值。我的代码有什么问题?
import ogr
driver = ogr.GetDriverByName('ESRI Shapefile')
fn = 'dist.shp'
dataSource = driver.Open(fn, 0)
layer = dataSource.GetLayer()
feature = layer.GetNextFeature()
dist = 233
while feature:
feature.SetField("dist", dist)
layer.SetFeature(feature)
feature = layer.GetNextFeature()
dataSource.Destroy()