Thanks - I was hoping I could rely on the library to do the intelligent truncation, but couldn't work it out.<div>Can I just clarify that the name to use with SetField would then be what is provided by your last line?<br>
<br></div><div> layer_defn.GetFieldDefn(last_field_idx).GetNameRef()</div><div><br></div><div>Cheers and thanks</div><div>Ole</div><div><br><div class="gmail_quote">On Tue, Sep 6, 2011 at 9:26 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">Selon Ole Nielsen <<a href="mailto:ole.moller.nielsen@gmail.com">ole.moller.nielsen@gmail.com</a>>:<br>
<br>
</div><div class="im">> Hi Even<br>
><br>
> Thanks again for all your help - all tests now pass using either gdal 1.6 or<br>
> 1.8. Just to summarise, there were three issues as I see them:<br>
><br>
><br>
</div>> 1. Bounding boxes for raster data are computed differently (but better)<br>
> in newer versions<br>
<br>
Specific to PixelIsPoint in the GTiff driver.<br>
<br>
> 2. While v1.6 of ogre would allow an single number of type numpy.ndarray<br>
<div class="im">> this is no longer allow. Casting it to a float solves the problem.<br>
<br>
</div>I wasn't aware it could work before. There's perhaps now an ambiguity on which<br>
method to use, due to the addition of new possibilities for SetField() (just a<br>
bling guess).<br>
<br>
> 3. New versions of ogre will not allow attribute names of length longer<br>
<div class="im">> than 10 (at least when using the ESRI driver). Formerly, I think it<br>
> silently<br>
> truncated, now it is up to the user. That's at least what I did.<br>
<br>
</div>I've a looked quickly a bit at your code and I've the feeling that you truncate<br>
yourself, instead of relying on OGR. The Shapefile driver does more than<br>
truncating. It also ensures uniqueness of the truncated names. For example, if<br>
you try creating "a_very_long_name" and "a_very_long_name_again", they will be<br>
respectively truncated to "a_very_lon" and "a_very_l_1". A safer solution to get<br>
the field name that got to the file would be to :<br>
<br>
field_defn = ogr.FieldDefn("a_very_long_name", ogr.OFTString)<br>
lyr.CreateField(field_defn)<br>
layer_defn = lyr.GetLayerDefn()<br>
last_field_idx = layer_defn.GetFieldCount() - 1<br>
real_field_name = layer_defn.GetFieldDefn(last_field_idx).GetNameRef()<br>
</blockquote></div><br></div>