0

From ARCGEN (Esri ArcInfo Generate) I want to create a DXF with distinguishable layers: import_polz.pol

enter image description here

The transformation to a three-dimensional shapefile runs flawlessly with gdal ogr2ogr:

ogr2ogr  -f "ESRI Shapefile"  export_lin.shp  -nlt LINESTRING -dim 3  import_polz.pol; ogrinfo -so -al export_lin.shp

or

ogr2ogr  -f "ESRI Shapefile"  export_pol.shp  -nlt POLYGON -dim 3  import_polz.pol; ogrinfo -so -al export_pol.shp

In the DBF, the ID assignments (ID,N,9,0) are correctly transferred with 1 and 2006, 2016, etc.

However, the conversion to a DXF file fails because of the assignment of the attributes to the layers:

ogr2ogr  -f "DXF"  export_lin.dxf  -nlt LINESTRING -dim 3  import_polz.pol; ogrinfo -so -al export_lin.dxf

The response looks like this:

ERROR 1: DXF layer does not support arbitrary field creation, field 'ID' not created. INFO: Open of export_lin.dxf' using driver DXF' successful. Layer name: entities Geometry: Unknown (any) Feature Count: 390 Extent: (0.000000, 0.000000) - (150.000000, 20.000000) Layer SRS WKT: (unknown) Layer: String (0.0) PaperSpace: Integer(Boolean) (0.0) SubClasses: String (0.0) Linetype: String (0.0) EntityHandle: String (0.0) Text: String (0.0)

In the forum I could only find the ten year old hint that the DXF format is complicated: Errors when converting MapInfo .tab to .dxf

However, a newer version of ogr2ogr now seems to know how to assign layers: https://gdal.org/drivers/vector/dxf.html#dxf-writer

However, I have no success with the instructions. Does anyone know how to assign the polygon ID to a DXF layer?

A solution with gdal or QGIS3 is desirable.

4
  • >"DXF layer does not support arbitrary field creation" To my knowledge only the geometry can be converted. It is not possible to transfer attributes to a DXF.
    – Mike
    May 16 at 7:24
  • The field 'ID' is probably a default value and is used by ogr2ogr for example in "export_lin.dbf". Source: c. "This is really a dummy as our fields are precreated." But according to source the variable "poFeatureDefn" must be defined to address a layer. Apparently this is also possible via -sql statement: converting-a-csv-to-dxf-using-ogr2ogr-from-the-command-line. Is anyone familiar with this? May 17 at 2:30
  • I don't quite understand your problem. This error message is more of a warning. The DXF should still be generated.
    – Mike
    May 17 at 6:16
  • The geometric elements have an ID. Layers can be defined in a DXF. For example, in the image above, a color corresponds to an ID or a layer. The correct assignment of the ID to a layer in a DXF would solve my problem. May 17 at 9:16

1 Answer 1

0

If you want to convert the ID column into a DXF layer, then you can use this code:

ogr2ogr -dialect sqlite -sql "SELECT  ID as Layer,  geometry from import_polz" ^
        -f "DXF"  export_lin.dxf  -nlt LINESTRING -dim 3  import_polz.pol
1
  • That's great. Many thanks to Mike. May 17 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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