Ticket #1737 (closed defect: duplicate)

Opened 6 years ago

Last modified 6 years ago

OGR Shapefile DS requires ds.Destroy() to comit attribute changes (Python)

Reported by: crschmidt Owned by: hobu
Priority: normal Milestone:
Component: PythonBindings Version: 1.4.0
Severity: normal Keywords: shapefile
Cc: warmerdam

Description

From within Python, with GDAL 1.4.0, I attempted to use the following code to commit a feature change to disk:

import ogr
ds = ogr.Open("TRAINS_ARC.shp", True)
l = ds.GetLayer(0)
f = l.GetFeature(1)
print f.GetFieldAsString(3)
f.SetField(3, "Ctps")
l.SetFeature(f)
l.SyncToDisk()

I placed this in a script (test.py), and ran it as:

python test.py

When I ran it multiple times, the field output did not change.

If I modified the file to add a "ds.Destroy()" to the end of it, the attribute value was changed.

I believe that I am using the 'standard' old-style Python bindings.

The data I attempted this on is available inside the (self-extracting zipfile)  ftp://data.massgis.state.ma.us/pub/shape/state/trains_shp.exe .

Change History

Changed 6 years ago by warmerdam

  • cc warmerdam added
  • keywords shapefile added

Changed 6 years ago by warmerdam

  • status changed from new to closed
  • resolution set to duplicate

Duplicate of #1456 ... sorry for soliciting the bug report. :-)

Note: See TracTickets for help on using tickets.