Disregard this inquiry - I've figured it out.

I needed to call lyr.SetFeature(feat); immediately after Feature.SetField

-Tom

From: [email protected] 
[mailto:[email protected]] On Behalf Of Finegan Thomas-QTF001
Sent: Friday, August 02, 2013 3:05 PM
To: [email protected]
Subject: [gdal-dev] shapefile; modify field value; write to disk

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
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to