[gdal-dev] shapefile; modify field value; write to disk
Finegan Thomas-QTF001
t.finegan at motorolasolutions.com
Fri Aug 2 14:45:45 PDT 2013
Disregard this inquiry - I've figured it out.
I needed to call lyr.SetFeature(feat); immediately after Feature.SetField
-Tom
From: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] On Behalf Of Finegan Thomas-QTF001
Sent: Friday, August 02, 2013 3:05 PM
To: gdal-dev at lists.osgeo.org
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130802/12e12449/attachment.html>
More information about the gdal-dev
mailing list