[gdal-dev] shapefile; modify field value; write to disk

Finegan Thomas-QTF001 t.finegan at motorolasolutions.com
Fri Aug 2 14:05:17 PDT 2013


Hello,
I'm using OGR via the swig/C# wrapper. Everything works great, except that I cannot get my changed field values saved to disk. I open the .shp for update, calls Feature.SetField and DataSource.SyncToDisk but the changed field value does not appear in the .dbf. No files are being written. How do I get my changed fields to persist back on the disk?

My code:

OSGeo.OGR.DataSource ds = OSGeo.OGR.Ogr.Open(shpFileName, 1);
OSGeo.OGR.Layer lyr = ds.GetLayerByIndex(0);
lyr.ResetReading();
OSGeo.OGR.Feature feat = lyr.GetNextFeature();
while (feat != null)
{
    feat.SetField("Lat", -999);
    feat = lyr.GetNextFeature();
}
ds.SyncToDisk();

-Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130802/fe5a0393/attachment.html>


More information about the gdal-dev mailing list