Python GDAL – Opening DGN Using Python with GDAL and OGR

dgnfionagdallimitationsogr

I'm trying to open a DGN file with Python.

I've tried with OGR:

driver = ogr.GetDriverByName("DGN")
file = driver.Open("C:\path_to_dgn\example.dgn")

which returns a NoneType object.

I've tried with Fiona:

fiona.open("C:\path_to_dgn\example.dgn")

which returns this error:

fiona.errors.DriverError: 'C:\path_to_dgn\example.dgn' not recognized
as a supported file format.

The DGN is a Microstation v8 file, I'm not sure if that changes anything.

Best Answer

GDAL/OGR and any software that is based on it (Fiona, GeoPandas etc.) can only read DGN < v.8 by default. From the DGN Driver doc:

Microstation DGN files from Microstation versions predating version 8.0 are supported for reading (a DGNv8 driver, using Teigha libraries, is available to read and write DGN v8 files).

The DGNv8 driver is not built-in by default and is only available when GDAL has been compiled against the proprietary (non open source) Open Design Alliance Teigha library

Related Question