Yes this seems to work. However, I get a huge amounts of warnings of the form<br>>>> lyr.CreateField(fd)<br>Warning 6: Normalized/laundered field name: 'A slightly long name' to 'A slightly'<br>0<br>
<br>They obviously tell what name has been derived, but I don'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"><<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">> Thanks - I was hoping I could rely on the library to do the intelligent<br>
> truncation, but couldn't work it out.<br>
> Can I just clarify that the name to use with SetField would then be what is<br>
> provided by your last line?<br>
><br>
> layer_defn.GetFieldDefn(last_field_idx).GetNameRef()<br>
<br>
</div>Yes<br>
<div><div></div><div class="h5"><br>
><br>
> Cheers and thanks<br>
> Ole<br>
><br>
> On Tue, Sep 6, 2011 at 9:26 PM, Even Rouault<br>
> <<a href="mailto:even.rouault@mines-paris.org">even.rouault@mines-paris.org</a>>wrote:<br>
><br>
> > Selon Ole Nielsen <<a href="mailto:ole.moller.nielsen@gmail.com">ole.moller.nielsen@gmail.com</a>>:<br>
> ><br>
> > > Hi Even<br>
> > ><br>
> > > Thanks again for all your help - all tests now pass using either gdal 1.6<br>
> > or<br>
> > > 1.8. Just to summarise, there were three issues as I see them:<br>
> > ><br>
> > ><br>
> > > 1. Bounding boxes for raster data are computed differently (but<br>
> > 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<br>
> > numpy.ndarray<br>
> > > this is no longer allow. Casting it to a float solves the problem.<br>
> ><br>
> > I wasn't aware it could work before. There's perhaps now an ambiguity on<br>
> > which<br>
> > method to use, due to the addition of new possibilities for SetField()<br>
> > (just a<br>
> > bling guess).<br>
> ><br>
> > > 3. New versions of ogre will not allow attribute names of length<br>
> > longer<br>
> > > 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>
> > I've a looked quickly a bit at your code and I've the feeling that you<br>
> > 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,<br>
> > if<br>
> > you try creating "a_very_long_name" and "a_very_long_name_again", they will<br>
> > be<br>
> > respectively truncated to "a_very_lon" and "a_very_l_1". A safer solution<br>
> > 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>
> ><br>
><br>
<br>
<br>
</div></div></blockquote></div><br>