Arnaud, You should use Layer.SetFeature(feat) to trigger the update in your shape file. Nicolas
-----Message d'origine----- De : gdal-dev-boun...@lists.osgeo.org [mailto:gdal-dev-boun...@lists.osgeo.org]de la part de Arnaud Vandecasteele Envoyé : jeudi 19 novembre 2009 10:21 À : gdal-dev@lists.osgeo.org Objet : [gdal-dev] OGR SetField() doesn't work Hi all, I'm trying to set a value on an existing field and existing Shapefile with python-ogr but it doesn't seems to work. Here is my works : ------------------------- import ogr import math import os layerNameF = os.path.join("myShape.shp") driver = ogr.GetDriverByName("ESRI Shapefile") Layer = driver.Open(layerNameF, True).GetLayer(0) for i in range(Layer.GetFeatureCount()) : feat = Layer.GetFeature(i) u = feat.GetFieldAsDouble('u10m') v = feat.GetFieldAsDouble('v10m') vitesse = math.sqrt((u**2)+(v**2)) feat.SetField('wspeed',vitesse) print type(feat.GetFieldAsDouble('wspeed')) print feat.GetFieldAsDouble('wspeed') feat.Destroy() ------------------------- the print feat.GetFieldAsDouble('wspeed') show me the good values. But when I open It again with Qgis or python the value is still 0.0. Do you know what I'm doing wrong? Thanks for any help Regards Arnaud
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev