[gdal-dev] DXF files: Is it possible to handle layer names? (I get only “entities”)

Mac Wind macwind2 at gmail.com
Sat Jun 23 01:28:06 PDT 2012


I'm using Python to extract the layers of a DXF file and convert them into SHP.

I began with:

------------------------
import ogr, os, sys
driver = ogr.GetDriverByName('DXF')
datasource = driver.Open('test1.dxf', 0)
numberLayers = datasource.GetLayerCount()
for i in range(0, numberLayers):
    layer = datasource.GetLayerByIndex(i)
    layerName = layer.GetName()
    numberFeatures = layer.GetFeatureCount()
    print 'Layer=%s|Features=%s' % (layerName, numberFeatures)
but I get one only layer: entities (as expected:
http://www.gdal.org/ogr/drv_dxf.html)
----------------

Obviously, it's the same information as if I execute: ogrinfo -so
test1.dxf entities

My DXF file contains several CAD layers: "ROADS", "ELEVATION", ... Is
it possible to handle these layer names with OGR? Thank you very much.


More information about the gdal-dev mailing list