I'm encountering an issue when trying to convert a GeoJSON file to DXF format. I'm using GDAL.Native version 3.9.1 for the conversion. The conversion process itself appears to be successful as it generates a DXF file without any obvious errors during the conversion stage.
However, when I attempt to open the resulting DXF file in AutoCAD, it fails to load. Oddly enough, when I use ogr2ogr (also in version 3.9.1) to perform the same conversion from GeoJSON to DXF, the generated DXF file can be opened in AutoCAD without any issues.
Here is the example geojson content:
{"type":"FeatureCollection","features":[{"type":"Feature","id":0,"properties":{"SubClasses":"AcDbEntity : AcDbLwPolyline","Layer":"mylayer","EntityHandle":"12E0"},"geometry":{"type":"Polygon","coordinates":[[[1,1],[1,2],[2,2],[2,1],[1,1]]]}}]}
Steps to reproduce the issue
C# codes:
GdalConfiguration.ConfigureOgr();
using var iSrc = Ogr.Open("data.json", (int)Access.GA_ReadOnly);
if (iSrc == null) return;
using var driver = Ogr.GetDriverByName("DXF");
using var oSrc = driver.CreateDataSource("data-dotnet.dxf", null);
for (var idx = 0; idx < iSrc.GetLayerCount(); idx++)
{
using var iLyr = iSrc.GetLayerByIndex(idx);
if (iLyr == null) continue;
var layerName = iLyr.GetName();
using var oLyr = oSrc.CopyLayer(iLyr, layerName, null);
}
What is the bug?
I'm encountering an issue when trying to convert a GeoJSON file to DXF format. I'm using GDAL.Native version 3.9.1 for the conversion. The conversion process itself appears to be successful as it generates a DXF file without any obvious errors during the conversion stage.
However, when I attempt to open the resulting DXF file in AutoCAD, it fails to load. Oddly enough, when I use ogr2ogr (also in version 3.9.1) to perform the same conversion from GeoJSON to DXF, the generated DXF file can be opened in AutoCAD without any issues.
Here is the example geojson content: {"type":"FeatureCollection","features":[{"type":"Feature","id":0,"properties":{"SubClasses":"AcDbEntity : AcDbLwPolyline","Layer":"mylayer","EntityHandle":"12E0"},"geometry":{"type":"Polygon","coordinates":[[[1,1],[1,2],[2,2],[2,1],[1,1]]]}}]}
Steps to reproduce the issue
C# codes:
ogr2ogr command:
ogr2ogr -f "DXF" data-ogr2ogr.dxf data.json
Versions and provenance
Windows 11 Gdal.Native 3.9.1 Gdal binary 3.9.1
Additional context
geojson-dxf.zip
data.json data-dotnet.dxf data-ogr2ogr.dxf