[gdal-dev] Fwd: NotImplementedError: Wrong number of arguments for overloaded function 'Feature_SetField'.

Even Rouault even.rouault at mines-paris.org
Sun Sep 4 05:16:09 EDT 2011


Le dimanche 04 septembre 2011 05:54:34, Ole Nielsen a écrit :
> Hi again and sorry for nagging, but do you have any hints as to what this
> error means
> 
> >    return _ogr.Feature_SetField(self, *args)
> > 
> > NotImplementedError: Wrong number of arguments for overloaded function
> > 'Feature_SetField'.
> > 
> >   Possible C/C++ prototypes are:
> >     SetField(OGRFeatureShadow *,int,char const *)
> >     SetField(OGRFeatureShadow *,char const *,char const *)
> >     SetField(OGRFeatureShadow *,int,int)
> >     SetField(OGRFeatureShadow *,char const *,int)
> >     SetField(OGRFeatureShadow *,int,double)
> >     SetField(OGRFeatureShadow *,char const *,double)
> >     SetField(OGRFeatureShadow *,int,int,int,int,int,int,int,int)
> >     SetField(OGRFeatureShadow *,char const *,int,int,int,int,int,int,int)
> 
> The input to the Python bindings is of the form
> SetField('STRUCT_DAMAGE_fraction', 0.346734256639)
> 
> i.e. one string argument (char*) followed by a float (double) which I
> thought would be matched by the third last header above. It works fine on
> version 1.6 but not version 1.8.
> 
> Can anyone tell me what has changed, what it means and how to work around
> it - please?
> 
Ole,

Unfortunately, I cannot explain your error, but I'm convinced it must be 
something particular with your installation. So I'd advise you to test on a 
fresh machine and/or clean a bit the packages you've installed on the one 
where you have problems.

Below a test I've just done to show you that SetField(string, double) 
definitely works with GDAL 1.8.0 under normal conditions. I've installed Ubuntu 
11.04 amd64 in a virtual machine, installed first python-gdal (1.6), then added 
ubuntugis-unstable PPA, installed qgis (1.7) :

even at even-virtual-machine:~$ dpkg -l | grep gdal
ii  gdal-bin                              1.8.0-2~natty2                             
Geospatial Data Abstraction Library - Utility programs
ii  libgdal1-1.6.0                        1.6.3-4build4                              
Geospatial Data Abstraction Library
ii  libgdal1-1.8.0                        1.8.0-2~natty2                             
Geospatial Data Abstraction Library
ii  python-gdal                           1.8.0-2~natty2                             
Python bindings to the Geospatial Data Abstraction Library

even at even-virtual-machine:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from osgeo import gdal
>>> from osgeo import ogr
>>> gdal.VersionInfo('')
'GDAL 1.8.0, released 2011/01/12'
>>> fielddefn = ogr.FieldDefn('STRUCT_DAMAGE_fraction', ogr.OFTReal)
>>> featuredefn = ogr.FeatureDefn()
>>> featuredefn.AddFieldDefn(fielddefn)
>>> feat = ogr.Feature(featuredefn)
>>> feat.SetField('STRUCT_DAMAGE_fraction', 0.346734256639)
>>> feat.DumpReadable()
OGRFeature():-1
  STRUCT_DAMAGE_fraction (Real) = 0.346734256639




More information about the gdal-dev mailing list