<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.5880" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=478074409-19112009><FONT face=Arial color=#0000ff
size=2>Arnaud,</FONT></SPAN></DIV>
<DIV><SPAN class=478074409-19112009><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=478074409-19112009> <FONT face=Arial
color=#0000ff size=2>You should use Layer.SetFeature(feat) to trigger the update
in your shape file.</FONT></SPAN></DIV>
<DIV><SPAN class=478074409-19112009><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=478074409-19112009> <FONT face=Arial
color=#0000ff size=2>Nicolas</FONT></SPAN></DIV>
<DIV><SPAN class=478074409-19112009></SPAN> </DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Message d'origine-----<BR><B>De :</B>
gdal-dev-bounces@lists.osgeo.org
[mailto:gdal-dev-bounces@lists.osgeo.org]<B>De la part de</B> Arnaud
Vandecasteele<BR><B>Envoyé :</B> jeudi 19 novembre 2009
10:21<BR><B>À :</B> gdal-dev@lists.osgeo.org<BR><B>Objet :</B>
[gdal-dev] OGR SetField() doesn't work<BR><BR></FONT></DIV>Hi
all,<BR><BR><BR>I'm trying to set a value on an existing field and existing
Shapefile with python-ogr but it doesn't seems to work.<BR>Here is my works
:<BR><BR>-------------------------<BR>import ogr<BR>import math<BR>import
os<BR><BR>layerNameF = os.path.join("myShape.shp") <BR>driver =
ogr.GetDriverByName("ESRI
Shapefile")
<DIV class="ii gt" id=:136> <BR>Layer = driver.Open(layerNameF,
True).GetLayer(0)<BR><BR>for i in range(Layer.GetFeatureCount())
:<BR> feat =
Layer.GetFeature(i)
<BR> u = feat.GetFieldAsDouble('u10m')<BR>
v = feat.GetFieldAsDouble('v10m') <BR> vitesse =
math.sqrt((u**2)+(v**2))
<BR> feat.SetField('wspeed',vitesse) <BR>
print type(feat.GetFieldAsDouble('wspeed'))<BR> print
feat.GetFieldAsDouble('wspeed')<BR> feat.Destroy()
<BR><BR>-------------------------<BR><BR>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.<BR><BR>Do you know what I'm
doing wrong?<BR><BR>Thanks for any
help<BR><BR><BR>Regards<BR><BR>Arnaud</DIV></BLOCKQUOTE></BODY></HTML>