[gdal-dev] Add a new filed to an existing shapefile

P Kishor punk.kish at gmail.com
Fri May 16 10:21:53 EDT 2008


On 5/16/08, Frank Warmerdam <warmerdam at pobox.com> wrote:
> Limei Ran wrote:
> > Hi:
> >
> > I am trying to add a new double field to an existing shapefile using the
> following codes.  But,  poLayer->CreateField failed.  Could you tell me what
> is wrong with the codes?
> >
>
> Limei,
>
> I believe the shapefile driver does not support adding fields to a shapefile
> layer that already has records/features in it.  This is fairly common in
> file
> based drivers, though it *could* be implemented for shapefiles if there was
> sufficient need.
>


In which case, use the Perl module XBase. It works really well, and
you can readily add new column to the DBF.

http://search.cpan.org/~janpaz/DBD-XBase-0.241/lib/XBase.pm

Working in conjunction with Geo::ShapeFile, you can manipulate
Shapefiles to your heart's content.

http://search.cpan.org/~jasonk/Geo-ShapeFile-2.52/lib/Geo/ShapeFile.pm

-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/


More information about the gdal-dev mailing list