[gdal-dev] “AttributeError: getZ” error when trying to get the elevation of DXF linestrings

Mac Wind macwind2 at gmail.com
Sun Jun 24 09:34:14 PDT 2012


Hello.

I'm using Python and OGR to extract the elevation of lines within a DXF file.

--------------
import ogr

driver = ogr.GetDriverByName('DXF')
datasource = driver.Open('test1.dxf', 0)

layers=datasource.ExecuteSQL( "SELECT DISTINCT Layer FROM entities" )
layer=datasource.GetLayerByIndex(0)

for i in range(0, layers.GetFeatureCount()):
        layerName = layers.GetFeature(i).GetFieldAsString(0)
        layer.SetAttributeFilter( "Layer='%s'" % layerName)
        print 'Layer=%s|Features=%s' % (layerName, layer.GetFeatureCount())

    for j in range(0, layer.GetFeatureCount()):
      myFeature = layer.GetNextFeature()
      myElevation = myFeature.GetGeometryRef().getZ(0)
-----------

But I get an "AttributeError: getZ" error when executing it.

What am I doing wrong? Thank you very much.


More information about the gdal-dev mailing list