3

This code works in QGIS 2.14 but not in 2.18. What do I have to change to be able to export properly to DGN. From what I understand, now it tries to save in microstation V8 format instead of v7.

I don't want to use "convert format" from the processing tool box, I'd really like to save directly to DGN without intermediary steps.

QgsVectorFileWriter.writeAsVectorFormat(
    couche_source,   #loaded layer
    enregistre_sous, #path to save as
    'utf8',
    QgsCoordinateReferenceSystem(2950, QgsCoordinateReferenceSystem.EpsgCrsId),
    'DGN',
    False,
    None,
    skipAttributeCreation = True,
    )

​I really don't know what to do, and I didn't find anything helpful to me.

Even when I try to save as DGN directly form QGIS it doesn't work. I get this error message :

Export to vector file failed.
Error: creation of layer failed (OGR error:creation option '' is not formatted with the key=value format)

And I did not modify anything in the options.

1
  • I can confirm the issue. Direct conversion with GDAL 2.4.0dev succeeds ogr2ogr -f DGN dgntest.dgn test.shp. If you need to have the job done, use GDAL even you do not like it. In any case, write to qgis-users mailing list and ask if this is a known issue or perhaps a new bug.
    – user30184
    Commented Aug 27, 2018 at 19:45

1 Answer 1

5

When I use the parameter 'DGN' as 'dgn', it successfully exports as DGN file in QGIS 2.18.22.

QgsVectorFileWriter.writeAsVectorFormat(
    couche_source,
    enregistre_sous,
    'utf8',
    QgsCoordinateReferenceSystem(2950, QgsCoordinateReferenceSystem.EpsgCrsId),
    'dgn', ### change 'DGN' into 'dgn'
    False,
    None,
    skipAttributeCreation = True
    )
3
  • 1
    I recommend to report this as a QGIS bug because it is now impossible to save into DGN by using the GUI.
    – user30184
    Commented Aug 28, 2018 at 6:32
  • 1
    I reported this issue: #19722 and #19723 Commented Aug 28, 2018 at 7:44
  • Thank you, it does work now. The only thing, I have to had '.dgn' to enregistre_sous. For the other format I don't have to, the extension are always added by default. Thanks again!
    – Starter2
    Commented Aug 29, 2018 at 17:19

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.