[gdal-dev] Update existing shape file

Frank Warmerdam warmerdam at pobox.com
Fri Aug 1 10:42:32 EDT 2008


wow wrote:
> Hi,
>   I wanna set new field value to an existing shape file which has been 
> opened with update access, but it doesn't work, my code like this:
>  
>   OGRFeature* pFeature = pLayer->GetFeature(2); 
>   int nIdx = pFeature->GetFieldIndex("Name");
>  pFeature->UnsetField(nIdx);
>  pFeature->SetField( "Name", "hanJ reiver" );
>  
>   Anyone give me some advices?

Chen Xuexia,

After modifying the in memory feature, you need to write it back to the
file using OGRLayer::SetFeature().

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    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list