[gdal-dev] Update ShapeLayer

Mateusz Loskot mateusz at loskot.net
Sun Aug 10 08:35:24 EDT 2008


wow wrote:
> Hi,
>   To update shape files. i got two questions: 

wow,

For Shapefile updating issues, read this post:

http://lists.osgeo.org/pipermail/gdal-dev/2008-August/017855.html

>  1. How could i delete a field from a shapelayer?

You have to create new Shapefile based on attributes schema of the 
exisiting Shapefile but removing unwanted field.

If your shapefile stores any features, it's not possible to update its 
structure.

>  2. How to set a value to a specified field of all records?
 > Could i use SQL sentences like "set field_name='value'" on the
> datasource of shapelayer? 

You can do it programmatically with a script or C/C++ program.
OGR SQL [1] engine does not support SQL UPDATE/INSERT commands.

[1] http://gdal.org/ogr/ogr_sql.html

BTW, it's a good idea to scan the archives of this mailing list, where 
you will find a lot of discussion about updating Shapefile issues.

Best regards
-- 
Mateusz Loskot, http://mateusz.loskot.net
Charter Member of OSGeo, http://osgeo.org


More information about the gdal-dev mailing list