[Gdal-dev] easy ogr question...
Will Cadell
wmc at timberline.ca
Tue Sep 19 12:33:03 EDT 2006
Thanks Frank,
No message I'm afraid but there are features, and I was wondering how
ogr would handle and 'empty' column. I assumed it would add nulls, but
hey ho seems like I'll have to make a new shapefile, copy the layer
definition then add the field then copy all the features to a new
shapefile... Does seem a bit cumbersome though... is there a better way
people can think of?
will
Frank Warmerdam wrote:
> Will Cadell wrote:
>> hi guys... am i just stupid or is there another way to add a field to a
>> shapefile other than:
>> ds = ogr.open("c:\shapefile.shp", True)
>> new_field = ogr.FieldDefn()
>> new_field.SetName(new_field_name)
>> new_field.SetType(new_field_type)
>> new_field.SetWidth(new_field_width)
>> layer = ds.GetLayer(0)
>> layer.CreateField(new_field)
>> ds.destroy
>>
>> because this doesn't work for me...
>
> Will,
>
> This does seem like the correct approach. Are there any features in the
> shapefile already? I'm pretty sure that adding a field only works when
> there are no features yet. If you aren't getting an error message then
> there is a clear bug here, and a bug report in bugzilla would be
> appreciated.
>
> Best regards,
--
Will Cadell
Remote Sensing and GIS Analyst
/\/\
/ \ \
/ Timberline
/ Forest Inventory Consultants
tel:(250) 562 2628 address: 1579 9th Ave,
skype: geo_will Prince George,
loc: 53.9135N, 122.7544W BC, Canada
www.timberline.ca
More information about the Gdal-dev
mailing list