[gdal-dev] [python] OGR feature to GeoJSON TypeError

Frank Broniewski brfr at metrico.lu
Mon Dec 19 05:02:13 EST 2011


Hi,

There seems to be a problem with the feature export to GeoJSON. I 
created a small example:

Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import os
 >>> from osgeo import ogr
 >>> ds = ogr.Open(os.path.join(os.getcwd(), 'points.shp'))
 >>> ds
<osgeo.ogr.DataSource; proxy of <Swig Object of type 
'OGRDataSourceShadow *' at 0x7ff61b905a50> >
 >>> for i in xrange(ds.GetLayerCount()):
...     layer = ds.GetLayer(i)
...     f = layer.GetNextFeature()
...     while f:
...             fj = f.ExportToJson()
...             f = layer.GetNextFeature()
...
Traceback (most recent call last):
   File "<stdin>", line 5, in <module>
   File "/usr/lib/python2.6/dist-packages/osgeo/ogr.py", line 2399, in 
ExportToJson
     'geometry': self.GetGeometryRef().ExportToJson(as_object=True),
TypeError: ExportToJson() got an unexpected keyword argument 'as_object'
 >>> from osgeo import gdal
 >>> gdal.VersionInfo()
'1730'
 >>>

Maybe it's only my rather old gdal version and this is already fixed, 
but I thought I mention this better

HTH

Frank

-- 
Frank BRONIEWSKI

METRICO s.à r.l.
géomètres
technologies d'information géographique
rue des Romains 36
L-5433 NIEDERDONVEN

tél.: +352 26 74 94 - 28
fax.: +352 26 74 94 99
http://www.metrico.lu


More information about the gdal-dev mailing list