[FWTools] CreateField on existing shape file

Bijoy Nair bijoyn at valuecad.com
Thu Jun 21 11:45:47 EDT 2007


Hi,
I am trying to add a new field on an existing shape file using ogr 
python bindings but it seems to fail. The same steps work correctly when 
a new shape file is created and a field is added to it.

 >>> from gdal import ogr
 >>> ds = ogr.Open('d:/temp/delete-dublin-shapes',update = 1)
 >>> lyr = ds.GetLayerByName('Zones')
 >>> field = ogr.FieldDefn('Project',ogr.OFTString)
 >>> field.SetWidth(100)
 >>> lyr.CreateField(field)
6

Any help would be appreciated.

Regards
Bijoy


More information about the FWTools mailing list