[Gdal-dev] Cannot update the shapefile's attribute with OGR

Frank Warmerdam fwarmerdam at gmail.com
Mon Aug 22 08:51:02 EDT 2005


On 8/22/05, nilarcs <nilarcs at gmail.com> wrote:
> Hi all
> 
> I'm a newbie with OGR. I can use it to read the shapefile, but when I
> want to update some attributes, it seemed that it didn't work. I have
> opened the shapefile with TRUE parameter , and used the ' SetField (
> int   iField,const char *  pszValue)' to give the field some new
> attribute . But when the program terminated , the attribute has no
> change, even adding the SyncToDisk() method.
> 
> I have no idea. How can I do ? Thanks for any advice!  If you can give
> some sample code, it's more better :)

Zhang,

OGR does not currently support "in place" update of shapefiles.  You
can append new shapes to an existing file in update mode, but not
modify existing shapes.  

This is a limitation of Shapelib and OGR that I would like to correct
at some point, but I wouldn't hold my breath waiting for it to be addressed.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list