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