3

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.

3
  • 1
    try driver=ogr.GetDriverByName("DGNv8") instead. Find more info on gdal.org/drivers/vector/dgnv8.html#vector-dgnv8
    – Ash
    Commented Oct 18, 2021 at 3:57
  • @Ash driver=ogr.GetDriverByName("DGNv8") returns None, doesn't look like its an OGR supported driver
    – lachlan
    Commented Oct 18, 2021 at 4:38
  • 1
    Yes, it's not supported by default. The DGN driver is limited because Microstation DGN files from Microstation versions predating version 8.0 are supported for reading. What's your DGN version?
    – Ash
    Commented Oct 18, 2021 at 5:42

1 Answer 1

8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.