[gdal-dev] OGR features list - python bindings

Nicol Hermann gdal at geoworld.de
Sun May 16 08:07:54 PDT 2021


I am facing difficulties returning a list of ogr features from a python
For each entry I am getting an error message like this:

[<osgeo.ogr.Feature; proxy of <Swig Object of type 'OGRFeatureShadow *'
at 0x7f75e870d4b0> >

This is the code I am using:

def generateRecordFormSplit( ogr, dblayer, dblayerDefn, sessionid ):
    cnt = 1
    featureList = []

    for feature in dblayer:
        geom = feature.GetGeometryRef()
        dblayerFeature = ogr.Feature(feature_def = dblayerDefn)
        dblayerFeature.SetGeometry( geom )
        dblayerFeature.SetField("sessionid", sessionid + "_" + str(cnt)
        featureList.append( dblayerFeature )
        cnt += 1

    return( featureList ) # <<-- Issue

Any hints what I am doing wrong and how to fix it.


More information about the gdal-dev mailing list