[gdal-dev] OGR SetField() doesn't work
Arnaud Vandecasteele
arnaud.sig at gmail.com
Thu Nov 19 04:20:59 EST 2009
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20091119/85dd5940/attachment.html
More information about the gdal-dev
mailing list